Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: fix data race at the aggressiveLockingDirty #913

Merged
merged 2 commits into from
Oct 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading