ISSUE DESCRIPTION Range-lock conflicts can strand waiters in stale queues A waiter that…
- User
ISSUE DESCRIPTION
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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /matrixone, current file: none) bash-$
- Assistant
I'll start by exploring the repository structure and searching for range-lock related code to understand the issue.
- Assistant
Searching the codebase for range-lock and waiter queue handling.
- Assistant
rg is not available, let me use grep instead.
- Assistant
Inspecting lockservice files related to range locks and waiter queues.
- Assistant
Reading the core lock and range-conflict handling code.
- Assistant
Let me continue reading lock.go, especially around the closeWaiter and stale mode comments.
- Assistant
Reading the closeWaiter function and related conflict handling.
- Assistant
Looking at lock_table_local.go for conflict handling when waiters move.
- Assistant
Let me read the doLock function and especially around line 189 where conflictKey is handled.
- Assistant
Continue reading around the conflict handling code.
- Assistant
Looking at how range lock conflicts add waiters and whether they clean up old queues.
- Assistant
Reading handleLockConflictLocked fully.
- Assistant
Inspecting waiter queue operations and related tests for gaps.
- Assistant
Let me also look at git log/diff for any recent incomplete work, and search for rangeLastWaitKey and closeWaiter tests.
- Assistant
Reading the test around rangeLastWaitKey and the recent fix.
- Assistant
Let me look at git show of the recent fix and also check if there's something incomplete. Utilities may have uncommitted changes or the issue is new.
- Assistant
Inspecting the hang fix and waiter structure for orphaned queue entries.
- Assistant
Reading waiter_queue notify and removeByTxnID helpers.
- Assistant
Opening the waiter queue file.
- Assistant
Inspecting waiter refs and whether a non-notifying remove already exists.
- Assistant
Looking for closeWaiter tests and more detailed hang scenario.
- Assistant
Looking at the comment in the test more carefully - after the fix that added closeWaiter for range: I see the issue you're describing with the test comment and the closeWaiter logic.
- Assistant
Looking at unlock path for when locks are deleted properly with release():
- Assistant
Checking waiter status transitions around wait / resetWait /notify.
- Assistant
Continue reading waiter notify and wait
- Assistant
Reading stay notify completion handling.
- Assistant
I understand the bug:
closeWaiterdoesn't remove the waiter from the queue. Implementing a proper remove and fixing cleanup for range locks. - Assistant
Implementing queue remove and fixing
closeWaiterso moved waiters leave stale queues. - Assistant
Now add the remove method after removeByTxnID
- Assistant
Need to navigate to that location first.
- Assistant
Now I can do the replace.
- Assistant
Now fix closeWaiter in lock.go
- Assistant
Updating the error path so range-lock waiters are cleaned up too.
- Assistant
Checking why cleanup is row-only and how beforeCloseFirstWaiter is used.
- Assistant
Only wake the next waiter when the removed waiter was head of the queue — matching notify semantics.
- Assistant
Fixing the comment typo and extending error-path cleanup to range locks.
- Assistant
Now update the error path to cleanup for range locks too.
- Assistant
Need to go to that line first.
- Assistant
Now replace.
- Assistant
Checking same-key retry handling to avoid removing a waiter just re-added to the same queue.
- Assistant
Updating handleLockConflictLocked to clean the stale queue before joining the new one, and to skip cleanup when the key is unchanged.
- Assistant
I'll rewrite handleLockConflictLocked toch cleanup before add, and skip when same key.
- Assistant
Writing a temporary test for closeWaiter, then running the lockservice tests.
- Assistant
Need to set GOPATH/GOMODCACHE
- Assistant
Need to fix unused imports in the temp test.
- Assistant
Need to open the file first.
- Assistant
Let me rewrite the file with fixed imports properly.
- Assistant
Need to remove the unused variables at the bottom of the test as well.
- Assistant
Remove leftover lines with bytes and runtime
- Assistant
Removing the duplicate closing braces.
- Assistant
Note: for "non-head leave" test, w1 is status notified but the channel is empty - remove just closes ref. When w1.close happens that's fine.
- Assistant
Core tests passed. Running the broader lockservice test suite next.
- Assistant
Finding which test failed.
- Assistant
Inspecting the two failing tests in detail.
- Assistant
Let me look at the test TestRowLockWithConflictAndUnlock
- Assistant
Let me open the test at line 3836
- Assistant
Checking how unlock of a waiting txn interacts with the waiter queue.
- Assistant
Let me look at Unlock for a txn that is waiting (doesn't hold locks)
- Assistant
Looking at cancelBlocks:
- Assistant
Checking the second failing test; the first appears to assert the old stranded-waiter behavior.
- Assistant
Removing the temporary test and running range-related tests. The RowLock test failure matches the intentional behavior change.
- Assistant
Investigating the TestLeakWaiterForErr failure.
- Assistant
Confirming TestLeakWaiterForErr is flaky (passed on retry). Running remaining related tests excluding the outdated assertion.
- Assistant
All other tests pass. Reviewing the final diff.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.