Skip to content
TheChatArchiveThe Chat Archive
GLMz-ai/glm-5.2· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Range-lock conflicts can strand waiters in stale queues A waiter that…

  1. 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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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-$

  2. GLM Assistant

    I'll start by exploring the repository structure to understand the codebase and then identify the relevant files related to range-lock conflicts.

  3. GLM Assistant

    This is the MatrixOne repository. The issue is about range-lock conflicts. Let me search for range-lock related code.

  4. GLM Assistant

    Let me look at the key files related to range locks and waiter queues.

  5. GLM Assistant

    Now let me look at the waiter queue and lock structures to understand the cleanup logic.

  6. GLM Assistant

    Now let me look at the waiter queue implementation to understand how waiters are removed.

  7. GLM Assistant

    Now let me look at the waiter.go file to understand the waiter struct.

  8. GLM Assistant

    Now let me search for the rangeLastWaitKey usage to understand the context better.

  9. GLM Assistant

    Now let me look at the existing tests for the range last wait key functionality.

  10. GLM Assistant

    Let me search for where c.idx is set.

  11. GLM Assistant

    Hmm, c.idx is never set in the range lock path. Let me look at how it's used. In acquireRowLockLocked, there's c.offset = idx and c.idx... wait no, let me re-read.

    Actually in acquireRowLockLocked:

    func (l *localLockTable) acquireRowLockLocked(c *lockContext) error {
    	n := len(c.rows)
    	for idx := c.offset; idx < n; idx++ {
    		row := c.rows[idx]
    		...
    		if ok && (...) {
    			hold, newHolder := lock.tryHold(l.logger, c)
    			if hold {
    				...
    				continue
    			}
    			// need wait for prev txn closed"
    			if c.w == nil {
    				c.w = acquireWaiter(c.waitTxn, "acquireRowLockLocked", l.logger)
    			}
    			c.offset = idx
    			return l.handleLockConflictLocked(c, key, lock)
    		}
    		...
    	}
    	c.offset = 0
    	...
    }
    

    So c.idx is used in doLock at line 174 c.rows[c.idx] and line 218 c.offset = c.idx. But it's never set... Let me search the whole codebase.

  12. GLM Assistant

    Let me look at the waiter_events.go to understand how waiters are checked.

  13. GLM Assistant

    Let me look at the git history of the relevant code to understand recent changes.

  14. GLM Assistant

    This is the most recent commit related to this issue. Let me look at the full diff.

  15. GLM Assistant

    Let me look at the test file around the range lock tests to understand expected behavior.

  16. GLM Assistant

    This test TestCannotHungIfRangeConflictWithRowMultiTimes describes exactly the scenario. Let me read the full test.

  17. GLM Assistant

    This test describes the exact scenario. Let me run it to understand the current behavior.

  18. GLM Assistant

    Let me run the existing test to understand the current behavior.

  19. GLM Assistant

    I need to set GOCACHE and HOME. Let me set up the environment.

  20. GLM Assistant

    Let me check the git branches and any related history.

  21. GLM Assistant

    Let me check if there are other implementations of the waiterQueue interface.

  22. GLM Assistant

    Let me look at the types.go to understand the Lock struct fully.

  23. GLM Assistant

    Now let me write a reproduction test to confirm the bug. Let me create a temporary test file.

  24. GLM Assistant

    Let me write a reproduction test to confirm the bug. First let me look at the waiter_queue_test.go for testing patterns.

  25. GLM Assistant

    Let me write a reproduction test to confirm the non-head stranding bug.

  26. GLM Assistant

    Let me look at setBlocked to set up the test correctly.

  27. GLM Assistant

    I found a key issue. Let me rewrite the reproduction for the head-with-others case, which is the actual bug. Let me fix the test setup.

  28. GLM Assistant

    I've confirmed the bug. The closeWaiter approach strands waiters in two cases: (1) when the moving waiter is not the head, and (2) when it is the head with other waiters behind it (it gets a spurious notification but is not removed, and the next waiter is not woken). Now let me implement a robust fix.

    Let me view the exact waiter_queue.go code to modify.

  29. GLM Assistant

    Now let me add the remove method to the interface:

  30. GLM Assistant

    Now let me refactor notify to extract notifyFirstLocked and add the remove method. Let me view the current notify:

  31. GLM Assistant

    Now let me refactor notify to use notifyFirstLocked and add the remove method:

  32. GLM Assistant

    Now let me update the cleanup in handleLockConflictLocked. Let me view the current code:

  33. GLM Assistant

    Let me check if the zap import is still used in lock_table_local.go after removing the error log:

  34. GLM Assistant

    Good, zap is still used. Now let me build and run the reproduction tests:

  35. GLM Assistant

    Both reproduction tests now pass. Let me run the existing relevant tests to ensure nothing breaks:

  36. GLM Assistant

    All passing. Let me confirm all the targeted tests passed (including the key ones):

  37. GLM Assistant

    Now let me run the waiter queue tests and a broader set of lockservice tests to ensure no regressions:

  38. GLM Assistant

    Let me run the broader concurrency/range lock tests to ensure robustness:

  39. GLM Assistant

    Let me run the reproduction tests with the race detector and reuse checker enabled to verify refcount correctness:

  40. GLM Assistant

    Let me add more repro cases to verify the recreated-same-key guard and the head-only deletion. Let me extend the repro test:

  41. GLM Assistant

    Let me verify the "wake the next waiter" by checking that wBehind gets notified in the head-with-others case:

  42. GLM Assistant

    The next waiter is correctly woken. Let me review the complete diff of my changes:

  43. GLM Assistant

    The diff looks clean. Let me run the key range/conflict tests with the race detector to be thorough:

  44. GLM Assistant

    All tests pass with the race detector. Now let me remove the temporary reproduction test file before submitting:

  45. GLM Assistant

    Let me do a final build and run the full lockservice test suite to confirm everything passes after cleanup:

  46. GLM Assistant

    The full test suite passes. Let me do a final review of the modified sections to ensure correctness:

  47. GLM Assistant

    Let me verify there are no other implementations or mocks of the waiterQueue interface that would need the new remove method:

  48. GLM Assistant

    Only one implementation exists, no mocks. Let me verify the whole repo still compiles (in case other packages reference these):

  49. GLM Assistant

    The build errors are only in the unrelated cgo package (missing C headers, a pre-existing environment issue), not in my changes. Let me confirm the lockservice and dependent Go packages build fine:

  50. GLM Assistant

    The lockop errors are from the pre-existing cgo C-header issue in the dependency chain, unrelated to my changes. The lockservice package itself builds and tests cleanly. Let me confirm lockservice compiles in isolation one more time:

  51. GLM Assistant

    All changes are complete and verified. Let me provide a final summary of the diff:

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