diff --git a/txnkv/transaction/pessimistic.go b/txnkv/transaction/pessimistic.go index efd9c3231..bb679f032 100644 --- a/txnkv/transaction/pessimistic.go +++ b/txnkv/transaction/pessimistic.go @@ -273,9 +273,7 @@ func (action actionPessimisticLock) handleKeyErrorForResolve( if lockInfo := keyErr.GetLocked(); lockInfo != nil && lockInfo.DurationToLastUpdateMs > 0 && lockInfo.DurationToLastUpdateMs < skipResolveThresholdMs { - return nil, true, tikverr.NewErrWriteConflictWithArgs( - c.startTS, lockInfo.LockVersion, lockInfo.LockForUpdateTs, lockInfo.Key, kvrpcpb.WriteConflict_Unknown, - ) + continue } // Extract lock from key error @@ -355,6 +353,9 @@ func (action actionPessimisticLock) handlePessimisticLockResponseNormalMode( if err != nil { return finished, err } + if len(locks) == 0 { + return false, nil + } // Because we already waited on tikv, no need to Backoff here. // tikv default will wait 3s(also the maximum wait value) when lock error occurs @@ -524,9 +525,9 @@ func (action actionPessimisticLock) handlePessimisticLockResponseForceLockMode( return false, nil } - // If the failedMutations is not empty and the error is not KeyIsLocked, the function should have already - // returned before. So this is an unreachable path. - return true, errors.New("Pessimistic lock response corrupted") + // This can be the situation where KeyIsLocked errors are generated by timeout, + // and we decide not to resolve them. Instead, just retry + return false, nil } if len(locks) != 0 {