Repository navigation
fix(lockservice): release forwarded txn before async wait - #25469
Merged
XuPeng-SH merged 1 commit intoJul 6, 2026
Merged
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
approved these changes
Jul 6, 2026
XuPeng-SH
left a comment
Contributor
There was a problem hiding this comment.
I did not find a blocker in this follow-up fix.
The mutex ownership change now matches the safe handleRemoteLock pattern: handleForwardLock releases the txn with defer, and the async callback no longer owns that unlock. The new regression test also covers the exact waiter-resume path that was hanging in #25466.
3 of 7 tasks
XuPeng-SH
added a commit
that referenced
this pull request
Jul 17, 2026
…1-dev (#25849) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Backport of #25447 to 4.1-dev. Fixes #25297 Fixes #25278 Related to #25279 ## What this PR does / why we need it: Backports the lockservice fix for owner-local remote lock deadlocks: - detects owner-local wait cycles rooted at the actual conflicting holders; - caps owner-side remote lock waits at two minutes by default; - retains remote lock metadata so rollback can release partially granted locks; - fixes deadlock detector enqueue bookkeeping and adds focused metrics; - removes completed synchronous waiters from the deadlock-event set before a waiter can be reused, and drops retained waiter references during shutdown (the relevant lockservice portion of #25792). Method_Lock is still protocol v1 and has no peer capability signal. The owner therefore keeps the dedicated ErrRemoteLockWaitTimeout internally but sends the existing ErrDeadLockDetected over v1. Every supported 4.1 origin recognizes that code as a whole-transaction rollback, so it issues remote unlock even for a partial multi-row grant during a rolling upgrade. The cherry-pick applies cleanly to the current 4.1-dev / v4.1.2 baseline. Follow-up #25469 remains unnecessary on this branch: 4.1 already releases the forwarded transaction lock with defer txn.Unlock() before entering the asynchronous wait path. ## Validation - go test -v ./pkg/lockservice -count=1 -timeout=20m — PASS (573.999s) - go build ./pkg/lockservice — PASS - go vet ./pkg/lockservice — PASS - focused waiter and V1 compatibility regression tests under -race -count=10 — PASS - go test ./pkg/frontend -run Test_isErrorRollbackWholeTxn -count=1 -timeout=5m (with repository CGO/rpath settings) — PASS The V1 compatibility test makes a two-row remote request acquire row 1 then time out on row 2, checks the legacy deadlock code, performs the old-origin whole-transaction unlock, and verifies row 1 is immediately lockable. --------- Co-authored-by: XuPeng-SH <[email protected]>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
Related to #25466
Related to #25297
Related to #25278
Related to #25279
What this PR does / why we need it:
PR #25466 backported #25447 to 3.0-dev, but
handleForwardLockstill held the active txn mutex until the async callback.When a forwarded lock request hits an async conflict,
l.lockreturns after queueing the waiter, while the callback is not called yet. Later the waiter worker retries by locking the same txn first, so it can block forever on the mutex that only the callback would release.This PR aligns
handleForwardLockwith the safe ownership pattern used byhandleRemoteLock: the handler releases the txn mutex withdefer, and the async callback no longer owns that unlock.It also adds a regression test that verifies a forwarded waiter resumes after the holder unlocks.
Validation:
A full package run on the same lockservice fix state also passed: