8000 fix(propdefs): Avoid posthog_propertydefinition constraint errors on v2 batch write retries by eli-r-ph · Pull Request #33768 · PostHog/posthog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(propdefs): Avoid posthog_propertydefinition constraint errors on v2 batch write retries #33768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 16, 2025

Conversation

eli-r-ph
Copy link
Contributor

Problem

Part two of a series of PRs attempting to address constraint violation DB errors seen in v2 batch write errors, this one targeting the posthog_propertydefinition table.

Changes

Don't attempt to update rows on conflict where property_type in the DB already equals the batch's record to-be-inserted. This should allow retries on partially-written failed batches to avoid constraint errors.

Did you write or update any docs for this change?

How did you test this code?

Locally and in CI

@eli-r-ph eli-r-ph requested a review from a team June 16, 2025 20:21
@eli-r-ph eli-r-ph self-assigned this Jun 16, 2025
Copy link
Contributor
@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Modified SQL query in property definitions batch processing to prevent constraint violations during retries. The key change addresses database errors by only updating property_type when the existing value is NULL OR different from the new value, avoiding unnecessary updates that could trigger constraint errors.

  • Fixes potential DB constraint errors in posthog_propertydefinition table during v2 batch write retries
  • Modified ON CONFLICT clause to be more selective about updates, preventing redundant operations
  • Warning: Possible typo in table name 'propertydefintion' (missing 'i') needs to be verified

1 file reviewed, 1 comment
Edit PR Review Bot Settings | Greptile

@eli-r-ph eli-r-ph merged commit df9f342 into master Jun 16, 2025
92 checks passed
@eli-r-ph eli-r-ph deleted the eli.r/fix-propdefs-pdef-db-err branch June 16, 2025 21:30
adamleithp pushed a commit that referenced this pull request Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0