Skip to content

ENG-54618: Fix Allocate unique-key conflict and transaction commit issue#82

Closed
and-bezzir wants to merge 1 commit intomasterfrom
ENG-54618-fix-transaction-issue
Closed

ENG-54618: Fix Allocate unique-key conflict and transaction commit issue#82
and-bezzir wants to merge 1 commit intomasterfrom
ENG-54618-fix-transaction-issue

Conversation

@and-bezzir
Copy link
Copy Markdown
Collaborator

@and-bezzir and-bezzir commented Apr 14, 2026

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 by Allocate on the same table, the old rows are still physically present, causing Error 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.BeginTx directly in a dedicated helper (commitPendingForAllocate) instead of s.Flush/s.Tx, which would trigger txNotifier, mark the main executor's TX as transient, and prevent CommitIfNeeded from committing — silently rolling back all changes.

  • Fix Flush not marking statements as executed: Flush now calls MarkAsExecuted() on flushed statements so the main executor skips them via NextNonExecuted.

  • Propagate caller context into sequencer: Changed sequencer.New(context.Background(), db)sequencer.New(ctx, db).

@and-bezzir and-bezzir requested a review from adranwit April 14, 2026 20:04
@adranwit
Copy link
Copy Markdown
Contributor

I'm convince it's the right fix,

@adranwit adranwit closed this Apr 14, 2026
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