Skip to content

[Bug]: Remote wait-for snapshot retries ignore context and can stall deadlock detection #25870

Closed

Description

@XuPeng-SH

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

4d78bc6

Other Environment Information

- Hardware parameters: N/A
- OS type: all
- Others: multi-CN lockservice path

Actual 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

  • GetWaitingList must 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: GetWaitingList accepts a context but does not pass it into fetchWhoWaitingMe.
  • pkg/lockservice/service.go: fetchTxnWaitingList is the deadlock-detector callback and calls the same synchronous traversal.
  • pkg/lockservice/txn.go: fetchWhoWaitingMe calls lockTable.getLock without a context or error return.
  • pkg/lockservice/lock_table_remote.go: getLock uses handleError and waitRemoteRetryBackoff, both background/unbounded variants.

Suggested direction:

  1. Thread a context and error result through the wait-for snapshot traversal and lockTable.getLock.
  2. Use handleErrorWithContext and waitRemoteRetryBackoffWithContext for remote retries.
  3. Give deadlock-detector snapshot work an explicit per-check deadline, since it has no external request context.
  4. Add deterministic tests for cancellation during GetTxnLock, bind refresh, and retry backoff, plus an eventual-recovery case.

Activity

  1. added
    kind/bug
    on Jul 19, 2026
  2. added theissue type on Jul 19, 2026
  3. added this to the MO-202607 milestone on Jul 19, 2026
  4. added
    severity/s0
    and removed on Jul 21, 2026
  5. added a commit that references this issue on Jul 22, 2026
    9dac43a
  6. assigned and unassigned on Jul 23, 2026
  7. added 3 commits that reference this issue on Sep 17, 2026
    3b22b10
    b7fad53
    c17b84e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions