diff --git a/txnkv/transaction/txn.go b/txnkv/transaction/txn.go index 6b402ef5d2..daccbe087c 100644 --- a/txnkv/transaction/txn.go +++ b/txnkv/transaction/txn.go @@ -1410,7 +1410,7 @@ func (txn *KVTxn) lockKeys(ctx context.Context, lockCtx *tikv.LockCtx, fn func() metrics.AggressiveLockedKeysDerived.Add(float64(filteredAggressiveLockedKeysCount)) metrics.AggressiveLockedKeysNew.Add(float64(len(keys))) - txn.resetTTLManagerForAggressiveLockingMode(len(keys) == 0) + txn.resetTTLManagerForAggressiveLockingMode(len(keys) != 0) if len(keys) == 0 { if lockCtx.Stats != nil { @@ -1582,12 +1582,12 @@ func (txn *KVTxn) resetPrimary(keepTTLManager bool) { } // resetTTLManagerForAggressiveLockingMode is used in a fair locking procedure to reset the ttlManager when necessary. -// This function is only used during the LockKeys invocation, and the parameter noNewLockToAcquire indicates whether +// This function is only used during the LockKeys invocation, and the parameter hasNewLockToAcquire indicates whether // there are any key needs to be locked in the current LockKeys call, after filtering out those that has already been // locked before the most recent RetryAggressiveLocking. // Also note that this function is not the only path that fair locking resets the ttlManager. DoneAggressiveLocking may // also stop the ttlManager if no key is locked after exiting. -func (txn *KVTxn) resetTTLManagerForAggressiveLockingMode(noNewLockToAcquire bool) { +func (txn *KVTxn) resetTTLManagerForAggressiveLockingMode(hasNewLockToAcquire bool) { if !txn.IsInAggressiveLockingMode() { // Not supposed to be called in a non fair locking context return @@ -1599,7 +1599,7 @@ func (txn *KVTxn) resetTTLManagerForAggressiveLockingMode(noNewLockToAcquire boo // acquirePessimisticLock requests, it will call ttlManager.run() again, but it's reentrant and will do nothing // as the ttlManager is already running. // * If the primary key is changed, the ttlManager will need to run on the new primary key instead. Reset it. - if !noNewLockToAcquire && !bytes.Equal(txn.aggressiveLockingContext.primaryKey, txn.aggressiveLockingContext.lastPrimaryKey) { + if hasNewLockToAcquire && !bytes.Equal(txn.aggressiveLockingContext.primaryKey, txn.aggressiveLockingContext.lastPrimaryKey) { txn.committer.ttlManager.reset() } }