Skip to content
TheChatArchiveThe Chat Archive
fable-5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

Range-lock conflicts can strand waiters in stale queues A waiter that moves to a new…

  1. 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.

  2. Assistant

    Now let me read waiter.go and waiter_events.go to understand waiter states and refs:

  3. Assistant

    Now let me check the git diff of commit 88d075766 to see the full current cleanup logic history, then check how upstream tests are structured:

  4. Assistant

    Now check the log.go conventions and add the log helper (or inline it). Also check whether zap is still used in lock_table_local.go:

  5. Assistant

    The test at line 1693 expects the missing-key branch to log without crashing. I'll add the log helper to log.go following its conventions:

  6. Assistant

    Now build and run the lockservice tests:

  7. Assistant

    Let me look for existing tests that exercise the waiter-move behavior, and check the beforeWait/afterWait test seams:

  8. Assistant

    All pass. Now add regression tests covering the fixed behaviors. Let me model them on the existing unit test style:

  9. Assistant

    Now append the regression tests at the end of lock_table_local_test.go:

  10. Assistant

    All new tests pass. Now run the full lockservice suite:

  11. Assistant

    Full suite passes (118s) and race-detector subset is clean. Let me review the final diff:

  12. Assistant

    The fix is complete and verified. Summary of what was wrong and what changed:

    The bug

    When a range-lock retry conflicts on a different key than the previous attempt (handleLockConflictLocked, lock_table_local.go), the old cleanup used Lock.closeWaiter on the previous key, which had three defects:

    1. Stranded waiters — closeWaiter never actually removes c.w from the previous queue unless the entire lock becomes removable. With other waiters queued behind it (or the key recreated with new holders), c.w stayed in the stale queue, and since the lock could already be holder-less, nothing would ever notify that queue again — waiters behind it hung until timeout.
    2. Spurious self-notification — the cleanup ran after setBlocked(c.w). When c.w was still first in the old queue, closeWaiter's hand-over notify was delivered to c.w itself (now blocking on the new key), waking its new wait with a stale value while the genuinely next waiter in the old queue was never woken.
    3. Unrelated state disturbed — if the previous key had been deleted and recreated by another txn, closeWaiter operated on a lock c.w never belonged to (potentially deleting it or notifying its first waiter prematurely).

    The fix (moveRangeConflictWaiterLocked)

    • Runs before c.w is added to the new conflict queue and set to blocking — c.w is still ready, so removal can't deliver a notification the upcoming wait would consume.
    • Missing previous key → logged no-op (the unlock path already released the queue's reference); recreated key → membership check (c.w must actually be in the queue) guarantees unrelated lock state is untouched.
    • Removes exactly c.w via the existing removeByTxnID; holders are never affected.
    • If the lock is holder-less and c.w was the designated first waiter, the next eligible waiter is notified; if the lock becomes fully empty, the entry is deleted from the store.

    No new interfaces — only existing package-internal waiterQueue/Lock methods are used, plus a log helper in log.go following existing conventions.

    Verification

    • 3 new unit tests: wake-next-waiter-in-stale-queue, preserve-recreated-lock, delete-empty-stale-lock — all pass.
    • Existing regression tests (TestCannotHungIfRangeConflictWithRowMultiTimes, TestHandleLockConflictLockedLogOnMissingRangeKey, all TestRangeLock*) pass.
    • Full pkg/lockservice suite passes (118s), and the range/conflict/deadlock subset is clean under -race.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.