Repository navigation
fix(lockservice): break owner-local remote lock deadlocks - #25447
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
left a comment
There was a problem hiding this comment.
I found multiple substantive blockers here.
- The new owner-side remote wait cap changes user-visible
lock_wait_timeoutsemantics.
RemoteLockOwnerWaitTimeout defaults to 2 minutes and is now always injected into remote lock requests. The effective async wait deadline then becomes the earlier of the session’s LockWaitTimeout and this owner-side cap. So a caller that explicitly configured a larger lock wait can now be aborted early at the owner’s 2-minute cap with ErrRemoteLockWaitTimeout.
That is a behavior change for valid workloads, not just protection against indefinite waits.
Suggested fix: only apply the owner-side cap when the client did not set LockWaitTimeout, or make the owner cap opt-in / disabled by default. At minimum, do not shorten an explicit caller timeout.
ErrRemoteLockWaitTimeoutstill records a lock that was never granted.
On the owner-timeout path, remoteLockTable.lock() still executes txn.lockAdded(...) before returning ErrRemoteLockWaitTimeout. But that error means the owner timed out the waiter before grant, so the origin txn did not acquire the lock.
This leaves the origin-side held-lock set inconsistent with reality and can poison later deadlock/observability paths that walk held locks.
Suggested fix: do not call txn.lockAdded for ErrRemoteLockWaitTimeout (or remove the key before returning), and add a regression that this error leaves no new held lock on the origin txn.
- The owner-local fast path is applied too broadly and does O(total locks/waiters) work under the table mutex on every row/exclusive conflict.
handleLockConflictLocked() now unconditionally calls detectOwnerLocalDeadlockLocked() for qualifying row/exclusive conflicts, and that helper scans the entire local lock store and all waiters while localLockTable.mu is held.
That is a real scalability regression risk: a conflict on one row now becomes table-wide work inside the critical section, blocking unrelated lock/unlock traffic behind it.
Suggested fix: restrict this fast path to the remote-owner cases that motivated the PR, or replace the full-store scan with a bounded graph walk rooted at the actual conflicting holders/waiters.
13d4538 to
b5229d9
Compare
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #25297
Fixes #25278
Related to #25279
What this PR does / why we need it:
This PR fixes a lockservice hang where a remote lock request can remain stuck at the lock-table owner while the origin transaction stays active and continues holding already-granted locks. In that state, existing deadlock detection may fail to break an owner-local wait cycle, and the origin-side remote lock RPC can wait for an extremely long time.
Changes:
ErrRemoteLockWaitTimeout, so the origin transaction is driven to rollback instead of waiting indefinitely.Validation: