Repository navigation
fix: lock ticket numbers are bakery numbers, not the wall clock - #379
Merged
Merged
Conversation
Two waiters arriving in the same millisecond took the same number and settled the tie on the token, so a later arrival could sort ahead of a holder that had already concluded it was first — a double hold the state-store suite reproduced one run in three. A waiter now takes one more than the largest ticket number it can see while its choosing marker is up, so a later arrival always sorts behind what it saw; only two simultaneous choosers share a number, and the doorway makes them see each other. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Sep 16, 2026
Merged
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
A correction to #376, caught by its own suite: the "release removes only the releaser's own ticket" test failed about one run in three with
brokeStaleundefined — the second acquirer had acquired without breaking anything, because two tickets created in the same millisecond carried the same wall-clock number and the tie fell to the random token, so the later arrival sorted ahead of a holder that had already concluded it was first. A double hold.The bakery takes its number from the floor, not the clock: with the choosing marker up, a waiter reads every ticket it can see and takes
max + 1. A later arrival therefore always sorts behind what it saw; only two simultaneous choosers share a number, and the doorway rule makes each wait for the other's ticket before deciding. Names still sort as strings (<15-digit number>-<pid>-<token>), so every observer agrees on the order.Test plan
…000000000000006-…and it waits behind the holder.tests/state-store.test.mjsrun ten times: 0 failures (the flaky [self-audit D-H5] Status lock release removes whoever's lock is present, including a newer holder's #227 test included).npm run build+npm test— 927 pass.🤖 Generated with Claude Code