fix(registration): prevent deadlocks and first-create races - #360
Draft
NikolayS wants to merge 3 commits into
Draft
fix(registration): prevent deadlocks and first-create races#360NikolayS wants to merge 3 commits into
NikolayS wants to merge 3 commits into
Conversation
Owner
Author
Testing and review evidenceHead: Exact-source verification
CI
Local PostgreSQL 17 evidence from the identical source tree
Original detailed evidence: #358 (comment) REVREV ran twice on the byte-identical source tree. The first pass found two blocking test-harness defects; both were fixed in the third commit. The second pass verified the exact tree, found zero blockers, and returned approve-and-merge. SOC2-only findings were ignored per repository policy. This PR remains open for owner review. It must not be merged without explicit authorization tied to #360. |
NikolayS
marked this pull request as draft
July 30, 2026 22:25
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
FOR NO KEY UPDATE, preserving registrar serialization without conflicting with subscription FK checksINSERT ... ON CONFLICT DO NOTHINGfollowed by a locking re-readFixes #357
Why
FOR UPDATEconflicts with theFOR KEY SHARElock taken by thesubscription.sub_consumer -> consumer.co_idforeign-key trigger. Togetherwith partition-slot lease renewal, that creates the registration/receive
AB-BA deadlock observed by Wave.
The old
SELECT ... FOR UPDATE; if not found INSERTprotocol also had no rowto lock during first registration, so concurrent creators could collide on
consumer_name_uq.Testing
consumer_name_uqon unmodifiedmaintests/two_session_registration_locks.shpasses with:register_consumer_atracing 4 cooperative members for one new groupreceive_partitionedbatchtests/run_all.sqltests/acceptance/run_acceptance.sqlbash build/transform.shgit diff --checkReview context
This recreates the original three commits from #358 after that PR was reverted because it was merged without the owner's review.
The resulting source tree is byte-for-byte identical to the tested PR 358 head and accidental merge commit. This PR is intentionally left open for proper review and requires explicit merge authorization tied to this PR.