ENG-54618: Fix Allocate unique-key conflict and transaction commit issue#82
Closed
and-bezzir wants to merge 1 commit intomasterfrom
Closed
ENG-54618: Fix Allocate unique-key conflict and transaction commit issue#82and-bezzir wants to merge 1 commit intomasterfrom
and-bezzir wants to merge 1 commit intomasterfrom
Conversation
…and sequence allocation improvements
Contributor
|
I'm convince it's the right fix, |
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.
Summary
Fix unique-key conflicts in
Allocate: The sequencer's transient INSERT (used to reserve auto-increment IDs) runs on a raw DB connection. When a handler queues DELETEs followed byAllocateon the same table, the old rows are still physically present, causingError 1062 Duplicate entry. The fix commits pending DML for the target table before the sequencer runs.Avoid poisoning the main executor's transaction lifecycle: Uses
db.BeginTxdirectly in a dedicated helper (commitPendingForAllocate) instead ofs.Flush/s.Tx, which would triggertxNotifier, mark the main executor's TX as transient, and preventCommitIfNeededfrom committing — silently rolling back all changes.Fix
Flushnot marking statements as executed:Flushnow callsMarkAsExecuted()on flushed statements so the main executor skips them viaNextNonExecuted.Propagate caller context into sequencer: Changed
sequencer.New(context.Background(), db)→sequencer.New(ctx, db).