Skip to content

Commit 950c122

Browse files
committed
kv: fix data race in TestReplicaTxnIdempotency
Fixes cockroachdb#107435. This commit deflakes `TestReplicaTxnIdempotency`. The race seen in the test was between an asynchronous read of a key attached to a raft proposal during a timestamp cache update and a mutation of that same underlying byte buffer by the test harness. We now make sure to clone the key before mutating the buffer. Release note: None
1 parent 771d3f7 commit 950c122

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/kv/kvserver/replica_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3728,12 +3728,12 @@ func TestReplicaTxnIdempotency(t *testing.T) {
37283728
return runWithTxn(nil, &args)
37293729
},
37303730
afterTxnStart: func(txn *roachpb.Transaction, key []byte) error {
3731-
args := deleteRangeArgs(key, append(key, 0))
3731+
args := deleteRangeArgs(key, roachpb.Key(key).Clone().Next())
37323732
args.Sequence = 2
37333733
return runWithTxn(txn, &args)
37343734
},
37353735
run: func(txn *roachpb.Transaction, key []byte) error {
3736-
args := deleteRangeArgs(key, append(key, 0))
3736+
args := deleteRangeArgs(key, roachpb.Key(key).Clone().Next())
37373737
args.Sequence = 2
37383738
return runWithTxn(txn, &args)
37393739
},

0 commit comments

Comments
 (0)