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
removeWaiterso moving range-lock waiters are taken out of stale queues without closing them, and waking the next waiter when needed. - Assistant
Adding tests for the new behavior:
- Assistant
The integration test passes on the original code; our changes broke it. Investigating the regression.
- Assistant
Identifying the bug: when
rangeLastWaitKeyequals the new conflict key, we add the waiter then immediately remove it from the same lock. Skipping cleanup when the keys match. - Assistant
Restoring tests and verifying the fix:
- Assistant
Integration test passes. Restoring and fixing unit tests:
- Assistant
All targeted tests pass. Running the full lockservice test suite:
- Assistant
Fixed stale-queue handling when a range-lock waiter moves to a new conflict key.
Problem
When a range lock waiter retried at a different key,
closeWaiteronly removed it if it was the first waiter and the lock had no holders. Otherwise the waiter stayed in the old queue while also being added to the new one, which could strand transactions.A second issue: cleanup ran even when
rangeLastWaitKey == key(same conflict on retry). That removed the waiter from the lock it had just been added to, causing a hang.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.