Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main
Commit ID
Other Environment Information
- Hardware parameters: N/A
- OS type: all
- Others: multi-CN lockservice pathActual Behavior
LockService.GetWaitingList(ctx, txnID) does not honor caller cancellation when a local transaction holds locks through a remote lock table.
The synchronous path is:
GetWaitingList(ctx)
-> activeTxn.fetchWhoWaitingMe(...)
-> remoteLockTable.getLock(...)
-> doGetLock() // one RPC attempt has defaultRPCTimeout
-> handleError(context.Background())
-> waitRemoteRetryBackoff()
-> retry forever
remoteLockTable.getLock has no context parameter and retries with background contexts. If the remote lock owner is unavailable while the allocator still returns the unchanged binding (or allocator refresh keeps failing), canceling or timing out the GetWaitingList context cannot terminate the call.
The production deadlock detector uses the same synchronous path through service.fetchTxnWaitingList. A persistent remote failure can therefore occupy a detector worker indefinitely; four affected checks can exhaust the current four-worker detector pool and prevent later deadlock checks from making progress.
This is pre-existing and was discovered while reviewing test-liveness changes in #25860; it is not introduced by that PR.
Expected Behavior
GetWaitingListmust return when its caller context is canceled or expires.- Remote wait-for graph lookup must have a bounded failure path.
- A failed remote snapshot must release its deadlock-detector worker instead of retrying forever.
- Temporary RPC failures should still retry while the operation's context remains live.
Steps to Reproduce
1. Construct a remoteLockTable with a Client that returns a retryable error for Method_GetTxnLock.
2. Make Method_GetBind return the same lock-table binding (or continue returning an error).
3. Create a local active transaction whose lockHolders reference that remote lock table.
4. Invoke LockService.GetWaitingList with a short deadline.
5. Observe that the deadline expires but the call remains in remoteLockTable.getLock retrying GetTxnLock/GetBind.
6. Repeat through deadlock detection for four transactions and observe all detector workers remain occupied.The existing TestGetLockRemoteWithRetry covers eventual recovery after one error, but there is no cancellation/timeout test for this path.
Additional information
Relevant code:
pkg/lockservice/service_observability.go:GetWaitingListaccepts a context but does not pass it intofetchWhoWaitingMe.pkg/lockservice/service.go:fetchTxnWaitingListis the deadlock-detector callback and calls the same synchronous traversal.pkg/lockservice/txn.go:fetchWhoWaitingMecallslockTable.getLockwithout a context or error return.pkg/lockservice/lock_table_remote.go:getLockuseshandleErrorandwaitRemoteRetryBackoff, both background/unbounded variants.
Suggested direction:
- Thread a context and error result through the wait-for snapshot traversal and
lockTable.getLock. - Use
handleErrorWithContextandwaitRemoteRetryBackoffWithContextfor remote retries. - Give deadlock-detector snapshot work an explicit per-check deadline, since it has no external request context.
- Add deterministic tests for cancellation during GetTxnLock, bind refresh, and retry backoff, plus an eventual-recovery case.
Activity
fix(lockservice): bound remote wait-for snapshot retries (#25999)
fix(lockservice): bound remote wait-for snapshot retries (matrixorigi…
fix(lockservice): bound remote wait-for snapshot retries (matrixorigi…
fix(lockservice): bound remote wait-for snapshot retries (matrixorigi…