Skip to content

fix: lock ticket numbers are bakery numbers, not the wall clock - #379

Merged
TheAmericanMaker merged 1 commit into
mainfrom
fix/lock-bakery-numbers
Sep 16, 2026
Merged

TheAmericanMaker merged 1 commit into
mainfrom
fix/lock-bakery-numbers

Conversation

@TheAmericanMaker

Copy link
Copy Markdown
Member

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 brokeStale undefined — 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

🤖 Generated with Claude Code

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>
@TheAmericanMaker
TheAmericanMaker merged commit 23b4326 into main Sep 16, 2026
5 checks passed
@TheAmericanMaker
TheAmericanMaker deleted the fix/lock-bakery-numbers branch September 16, 2026 01:46
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.

1 participant