fix(lockservice): backport fenced orphan unlock to 4.1-dev - #25652
Merged
XuPeng-SH merged 6 commits intoJul 13, 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? |
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:
refs #25553
refs #22115
refs #22791
Backport of #25563 to
4.1-dev.What this PR does / why we need it:
This PR backports the lockservice orphan-unlock safety fix from #25563. It prevents orphan cleanup from releasing a holder while its TN Commit can still finish, and ensures every exceptional orphan unlock carries a timestamp that fences stale waiters.
Root cause
The incident follows the single-TN-shard 1PC branch and is a race between the TN Commit handler and lockservice orphan cleanup:
LockTableAllocator.Validrecords the transaction as committing.cleanCommitStatecan apply an unavailable or stale CN active-transaction view to the allocator state.CannotCommitloses the in-flight Commit state, it can incorrectly report that the holder is safe to unlock.Fix
Validcalls until their matchingFinishCommit, including duplicate or concurrent Commit requests.cannotCommittombstones when the active-transaction query fails.CannotCommit:(upper.PhysicalTime + 1, 0).Scope and risk
The normal Commit path adds allocator-local state operations only. It adds no RPC and removes state as soon as the final Commit attempt returns. Normal lock acquisition, wait timeout, isolation, and ordinary commit/unlock behavior are unchanged.
The deployment invariant for this hotfix is one TN shard per transaction (
len(TNShards) == 1). The retained multi-TN asynchronous Commit branch is outside this PR's supported scope.If a TN Commit itself never returns, the holder remains protected because releasing a lock while that Commit can still become visible is unsafe. Existing TN recovery remains responsible for resolving that condition.
Validation
go test -race ./pkg/lockservice -run 'Test(CannotCommitWaitsForAllCommitAttempts|CleanCommitStateKeepsInflightCommit|CleanerPreservesCannotCommitOnActiveTxnQueryError|CleanerDoesNotDeleteTombstoneCreatedAfterServiceSnapshot|CannotCommitGenerationRefresh|NewFenceTS)' -count=1go test ./pkg/lockservice -count=1go test ./pkg/txn/service -run 'TestCommitWithLockTables' -count=1go vet ./pkg/lockservicego vet ./pkg/txn/service