fix(upsert): rewrite plain INSERT into UNIQUE-keyed tables as ON CONFLICT DO UPDATE#12
Draft
JorisM wants to merge 1 commit into
Draft
fix(upsert): rewrite plain INSERT into UNIQUE-keyed tables as ON CONFLICT DO UPDATE#12JorisM wants to merge 1 commit into
JorisM wants to merge 1 commit into
Conversation
…LICT DO UPDATE Plain INSERT into shim-added UNIQUE-keyed tables (statistics_bandwidth, statistics_media, metadata_item_settings) raises unique_violation on PG; PMS does not catch and aborts with DB::Exception. Extend transform_insert to emit ON CONFLICT DO UPDATE for plain INSERTs whose target table has known conflict columns. DO UPDATE (not DO NOTHING) is intentional so the trailing RETURNING id clause in cached_write still returns the row id. Verified via cargo run --example crash_repro and live pilot pod.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft pending live pilot verification. Plain INSERTs into shim-added UNIQUE-keyed tables (statistics_bandwidth, statistics_media, metadata_item_settings) hit unique_violation on PG and PMS aborts. Extends transform_insert to emit ON CONFLICT DO UPDATE for plain INSERTs whose target table has known conflict columns. DO UPDATE (not DO NOTHING) is intentional — see #3.
Detailed write-up: docs/debug/plex-pg-db-exception-bug-report.md (to be filed alongside).