Repository navigation
fix(lock): a node that loses to a lower slot leaves a waiting mark so holders give it a turn - #143
Merged
Merged
Conversation
… holders give it a turn A node in a higher slot that lost a claim cleared its slot and only polled. A lower slot that released a lock and claimed it again right after its cached hold expired never saw the waiter, and its turn restarted with every claim, so the higher slot could wait until the 30 s timeout. The loser now writes a waiting mark, which conflicts with no claim. A holder that wins a claim and sees a live node's mark ends its turn 250 ms after it first saw one, even across fresh claims, then yields for YieldGap. Marks count only while their node is alive in the registry (or, without a registry, until they are stale), and the waiter clears its mark when its Acquire ends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes the starvation found in the #135 review: a higher slot waiting while a lower slot re-claims right after each cache expiry. The waiting-mark idea comes from the extent-trees author, with one change. A holder does not yield on every release once it sees a mark. Instead its turn runs 250 ms from the first sighting, across fresh claims, and then ends with the usual 50 ms yield. This keeps batching under contention and bounds the wait to about 300 ms per holder ahead.
Marks conflict with nothing, so the safety and no-cycle arguments are unchanged. A mark counts only while its writer is alive in the registry and is still its occupant (without a registry, until it is stale). A dead waiter's mark is ignored, and adoption clears it.
Evidence (.68):
TestMultiNodeRestartKeepsPeerJournalfails 1 of 5 runs on main as well. The test reads files right after the replay starts. Not fixed here.🤖 Generated with Claude Code