You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
remoteLockTable.unlock() in lock_table_remote.go has a retry loop with no global deadline. When the remote CN returns a permanent error code not classified as needRetry=false, the unlock goroutine loops forever with exponential backoff, leaking a goroutine and never releasing the lock.
Root Cause
lock_table_remote.go:212-258:
func (l*remoteLockTable) unlock(txn*activeTxn, paramsUnlockParam) error {
for {
err, needRetry:=l.doUnlock(txn, params) // context.Background(), 10s timeout per attemptiferr!=nil {
l.handleError(txn, err)
}
if!needRetry { returnerr }
// exponential backoff, capped at 5s, then retry
}
}
handleError() (line 492-506) only sets needRetry=false for:
ErrCodeLockBindInvalid
ErrCodeNotLeaseHolder
requestTimeout combined with bind changed
Permanent error codes that return needRetry=true:
Error code
Behavior
ErrCodeCannotLockTable
needRetry=true (permanent)
ErrCodeCannotAddTableLockGroup
needRetry=true (permanent)
ErrLockBindConflict
needRetry=true (permanent)
Impact
Goroutine leak: each unlock on permanent error hangs forever
Lock leak: active transaction locks not released on remote CN
Triggers during: CN rolling restart, lock table migration, allocator misconfiguration
Suggested Fix
Option 1: Add global deadline (e.g. 5 min) to unlock retry loop
Option 2: Add permanent error codes to needRetry=false list in handleError()
Related
Discovered during multi-CN transaction unhappy-path audit. See also: #25195, #25198
Closing after re-checking this against both current main and the repository snapshot immediately before this issue was created.
The report's central execution path does not match the code:
remoteLockTable.unlock/doUnlock has no needRetry return value.
ErrCodeCannotLockTable, ErrCodeCannotAddTableLockGroup, and ErrLockBindConflict do not exist in the repository.
The remote Unlock handler calls service.Unlock; an already-missing transaction returns success.
The retry loop handles transport/unknown-delivery failures and terminates on successful unlock or an allocator-confirmed bind change.
This retry behavior protects a required safety invariant: when an Unlock response is lost, the caller cannot conclude that the remote lock was not acquired or released. Adding an arbitrary global deadline could therefore abandon a live remote lock.
No code change should be made from the suggested options. Reopen or file a narrower issue if there is a reproducible Method_Unlock error that keeps the bind unchanged indefinitely; please include the exact returned error, allocator availability, and logs. Availability hardening such as service-lifecycle cancellation or background retry ownership would need a separate design.
Activity
aptend commentedon Jul 10, 2026
Closing after re-checking this against both current main and the repository snapshot immediately before this issue was created.
The report's central execution path does not match the code:
This retry behavior protects a required safety invariant: when an Unlock response is lost, the caller cannot conclude that the remote lock was not acquired or released. Adding an arbitrary global deadline could therefore abandon a live remote lock.
No code change should be made from the suggested options. Reopen or file a narrower issue if there is a reproducible Method_Unlock error that keeps the bind unchanged indefinitely; please include the exact returned error, allocator availability, and logs. Availability hardening such as service-lifecycle cancellation or background retry ownership would need a separate design.