Skip to content

Commit

Permalink
fix: don't treat it as WriteConflict, simply retry
Browse files Browse the repository at this point in the history
Signed-off-by: ekexium <eke@fastmail.com>
  • Loading branch information
ekexium committed Mar 31, 2023
1 parent 956ce1f commit 1c7c201
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions txnkv/transaction/pessimistic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 1c7c201

Please sign in to comment.