From 23acd9e714d89fe915ce7b54b5ac39b90035f38a Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Wed, 26 Jul 2023 16:19:02 +0800 Subject: [PATCH] *: fix data race at the aggressiveLockingDirty Signed-off-by: Weizhen Wang --- txnkv/transaction/txn.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/txnkv/transaction/txn.go b/txnkv/transaction/txn.go index 6d90a1658..2d5407a39 100644 --- a/txnkv/transaction/txn.go +++ b/txnkv/transaction/txn.go @@ -158,7 +158,7 @@ type KVTxn struct { resourceGroupName string aggressiveLockingContext *aggressiveLockingContext - aggressiveLockingDirty bool + aggressiveLockingDirty atomic.Bool forUpdateTSChecks map[string]uint64 } @@ -1233,7 +1233,7 @@ func (txn *KVTxn) lockKeys(ctx context.Context, lockCtx *tikv.LockCtx, fn func() Value: val, ActualLockForUpdateTS: actualForUpdateTS, } - txn.aggressiveLockingDirty = true + txn.aggressiveLockingDirty.Store(true) } else { setValExists := tikv.SetKeyLockedValueExists if !valExists { @@ -1391,7 +1391,7 @@ func hashInKeys(deadlockKeyHash uint64, keys [][]byte) bool { // IsReadOnly checks if the transaction has only performed read operations. func (txn *KVTxn) IsReadOnly() bool { - return !(txn.us.GetMemBuffer().Dirty() || txn.aggressiveLockingDirty) + return !(txn.us.GetMemBuffer().Dirty() || txn.aggressiveLockingDirty.Load()) } // StartTS returns the transaction start timestamp.