Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
Signed-off-by: ekexium <ekexium@gmail.com>
  • Loading branch information
ekexium committed Feb 17, 2023
1 parent ab3c96e commit e3bcfae
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions txnkv/transaction/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -1142,8 +1142,13 @@ func (txn *KVTxn) lockKeys(ctx context.Context, lockCtx *tikv.LockCtx, fn func()
}

// note that lock_only_if_exists guarantees the response tells us whether the value exists
keyIsNotLocked := lockCtx.LockOnlyIfExists && !valExists
if txn.IsInAggressiveLockingMode() && !keyIsNotLocked {
// TODO: Fix the calculation when aggressive-locking is active
if lockCtx.LockOnlyIfExists && !valExists {
skippedLockKeys++
continue
}

if txn.IsInAggressiveLockingMode() {
txn.aggressiveLockingContext.currentLockedKeys[keyStr] = tempLockBufferEntry{
HasReturnValue: lockCtx.ReturnValues,
HasCheckExistence: lockCtx.CheckExistence,
Expand All @@ -1155,11 +1160,6 @@ func (txn *KVTxn) lockKeys(ctx context.Context, lockCtx *tikv.LockCtx, fn func()
if !valExists {
setValExists = tikv.SetKeyLockedValueNotExists
}
// TODO: Fix the calculation when aggressive-locking is active
if lockCtx.LockOnlyIfExists && !valExists {
skippedLockKeys++
continue
}
memBuf.UpdateFlags(key, tikv.SetKeyLocked, tikv.DelNeedCheckExists, setValExists)
}
}
Expand Down

0 comments on commit e3bcfae

Please sign in to comment.