Range-lock conflicts can strand waiters in stale queues A waiter that moves to a new…
- User
Range-lock conflicts can strand waiters in stale queues
A waiter that moves to a new range conflict must no longer remain in stale queues. Cleanup must preserve unrelated lock state, wake the next eligible waiter when necessary, and continue to work when the previous key disappeared or was recreated.
Interface
No new interfaces are introduced.
- Assistant
Investigating range-lock waiter queue handling when conflicts move to a new range.
- Assistant
Implementing
detachWaiterto remove waiters from old queues when range conflicts move—closeWaiteronly handled the first waiter and left others stranded. - Assistant
Adding tests for detach/extract behavior and stale-queue cleanup.
- Assistant
Fixing test cleanup to prevent reuse checker panics.
- Assistant
Fixing ordering: detach from the old queue before adding to the new one, and skip re-adding when the conflict key is unchanged.
- Assistant
Baseline passes; our changes broke the test. Restoring and debugging.
- Assistant
Skipping
addWaiteron the same key was wrong whennotifyAllhad already cleared the queue. Fixing by re-adding only when the waiter isn't already queued: - Assistant
Fixed range-lock waiters getting stranded when a conflict moves to a different key.
Problem
When a range lock waiter retried on a new conflict key, cleanup used
closeWaiter, which only worked if the waiter was first and there were no holders. Waiters could remain in old queues (e.g. still listed atk4while actually waiting atk2), causing hangs like inTestCannotHungIfRangeConflictWithRowMultiTimes.Fix
extractonwaiterQueue— removes a specific waiter by pointer and releases only its queue reference.detachWaiteronLock— extracts the waiter, preserves holders and other waiters, and notifies the next waiter when the removed one was first with no holders.handleLockConflictLocked— for range locks:- Detach from
rangeLastWaitKeywhen the conflict key changes - Re-add only if the waiter is not already in the new queue (handles
notifyAllclearing the queue on the same key)
- Detach from
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.