Skip to content

Commit

Permalink
kv: shallow copy BatchRequest on mutate in tryBumpBatchTimestamp
Browse files Browse the repository at this point in the history
This avoids a data race on tryBumpBatchTimestamp, which was fallout from the
new logging introduced in ba13697.

Fixes: #124553

Release note: None
  • Loading branch information
lyang24 committed May 23, 2024
1 parent d146ecf commit bc5460b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/kv/kvserver/replica_batch_updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,12 @@ func tryBumpBatchTimestamp(
}
log.VEventf(ctx, 2, "bumping batch timestamp to: %s from read: %s, write: %s",
ts, ba.Txn.ReadTimestamp, ba.Txn.WriteTimestamp)
ba.Txn = ba.Txn.Clone()
ba.Txn.BumpReadTimestamp(ts)
ba.Timestamp = ba.Txn.ReadTimestamp // Refresh just updated ReadTimestamp
txn := ba.Txn.Clone()
txn.BumpReadTimestamp(ts)
readTs := ba.Txn.ReadTimestamp
ba = ba.ShallowCopy()
ba.Txn = txn
ba.Timestamp = readTs
// Refresh just updated ReadTimestamp
return true
}

0 comments on commit bc5460b

Please sign in to comment.