Skip to content

Commit

Permalink
make it consistent with master
Browse files Browse the repository at this point in the history
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
  • Loading branch information
sticnarf committed Apr 12, 2021
1 parent 25a843a commit 490c9a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions store/tikv/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,9 @@ type ErrKeyExist struct {
func (k *ErrKeyExist) Error() string {
return k.AlreadyExist.String()
}

// IsErrKeyExist returns true if it is ErrKeyExist.
func IsErrKeyExist(err error) bool {
_, ok := errors.Cause(err).(*ErrKeyExist)
return ok
}
3 changes: 1 addition & 2 deletions store/tikv/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,7 @@ func (txn *KVTxn) LockKeys(ctx context.Context, lockCtx *kv.LockCtx, keysInput .
txn.us.UnmarkPresumeKeyNotExists(key)
}
}
_, isErrKeyExist := errors.Cause(err).(*ErrKeyExist)
keyMayBeLocked := terror.ErrorNotEqual(kv.ErrWriteConflict, err) && !isErrKeyExist
keyMayBeLocked := terror.ErrorNotEqual(kv.ErrWriteConflict, err) && !IsErrKeyExist(err)
// If there is only 1 key and lock fails, no need to do pessimistic rollback.
if len(keys) > 1 || keyMayBeLocked {
wg := txn.asyncPessimisticRollback(ctx, keys)
Expand Down

0 comments on commit 490c9a6

Please sign in to comment.