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 and stale-queue cleanup in the codebase.
- Assistant
Implementing the fix:
closeWaiteronly removes the first waiter, so range-lock waiters that move to a new conflict can remain in stale queues. Updating it to remove the waiter regardless of position and wake the next waiter when needed. - Assistant
Adding an integration test for range-lock conflict movement, then running tests.
- Assistant
Fixing tests:
closeWaiteronly runs when there are no holders. - Assistant
Fixing tests:
newConflictisn't stored in the lock table, and the second test reuses a waiter already inblockingstate. - Assistant
Running the full lockservice test suite to check for regressions.
- Assistant
Fixed stale-queue stranding when a range-lock waiter moves to a new conflict.
Root cause:
closeWaiteronly removed a waiter when it was first in the queue. Range-lock waiters that retried and conflicted on a different key could remain in the old queue, blocking cleanup and preventing the next waiter from being woken.Fix in
closeWaiter(lock.go):- Remove the waiter via
removeByTxnIDregardless of queue position - If it was first and others remain, notify the next eligible waiter
- Delete the lock entry only when it becomes fully empty (no holders, no waiters)
- Leave locks with active holders untouched
This uses the existing
waiterQueueinterface — no new APIs.Behavior preserved:
- Unrelated holders and waiters stay in place
- First-waiter removal still wakes the next waiter
- Missing previous keys are handled (logged, no panic)
- Recreated keys are cleaned via a fresh
store.Get
Tests added:
- Remove the waiter via
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.