Skip to content

Commit

Permalink
*: fix data race at the aggressiveLockingDirty (#913)
Browse files Browse the repository at this point in the history
Signed-off-by: Weizhen Wang <[email protected]>
Co-authored-by: disksing <[email protected]>
  • Loading branch information
hawkingrei and disksing authored Oct 8, 2023
1 parent a05564b commit 18a8414
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions txnkv/transaction/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ type KVTxn struct {
resourceGroupName string

aggressiveLockingContext *aggressiveLockingContext
aggressiveLockingDirty bool
aggressiveLockingDirty atomic.Bool

forUpdateTSChecks map[string]uint64
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 18a8414

Please sign in to comment.