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
I'll investigate the range-lock waiter queue implementation and how cleanup handles stale queues when a waiter moves to a new range conflict.
- Assistant
The bug is in
closeWaiter: it only handles the first waiter and skips removal when holders exist, leaving moved range-lock waiters in stale queues. I'll fix that and add tests. - Assistant
Adding tests for the fixed behavior:
- Assistant
The tests leak waiter refs because the queue isn't closed. Fixing cleanup:
- Assistant
Restoring
closeWaiterfor the row-lock abort path and adding a dedicatedmoveWaiterfor range-lock conflict moves. - Assistant
Removing the
waiterQueueinterface extension per the requirements, and investigating the test hang. - Assistant
The bug is that
moveWaiterruns afteraddWaiteron the same key, so it removes the waiter we just enqueued. Skipping cleanup when the old and new conflict keys match. - Assistant
All tests pass. Adding a test for the same-key skip case and finalizing.
- Assistant
Fixed stale-queue handling when a range-lock waiter moves to a new conflict key.
Problem
closeWaiteronly removed a waiter when it was the first in the queue and no holders were present. When a range waiter retried on a different key, it could stay in the old queue. Worse, cleanup ran afteraddWaiteron the new key, so when the conflict key was unchanged it could remove the waiter that had just been enqueued.Fix
-
moveWaiter(lock.go) — range-specific cleanup that:- Removes the waiter from any position in the queue
- Wakes the next waiter when the removed waiter was first and there are no holders
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.