Skip to content

Commit

Permalink
kv: fix TestRPCRetryProtectionInTxn/CanForwardReadTimestamp=true
Browse files Browse the repository at this point in the history
The test was overwriting the `Header.CanForwardReadTimestamp` field when
assigning the BatchRequest.Header.

Epic: None
Release note: None
  • Loading branch information
nvanbenschoten committed May 13, 2023
1 parent 7a311d8 commit e7a2016
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions pkg/kv/kvserver/replica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4721,27 +4721,22 @@ func TestRPCRetryProtectionInTxn(t *testing.T) {

// Send a batch with put & end txn.
ba := &kvpb.BatchRequest{}
ba.Txn = txn
ba.CanForwardReadTimestamp = noPriorReads
put := putArgs(key, []byte("value"))
et, _ := endTxnArgs(txn, true)
et.LockSpans = []roachpb.Span{{Key: key, EndKey: nil}}
ba.Header = kvpb.Header{Txn: txn}
ba.Add(&put)
ba.Add(&et)
ba.Add(&put, &et)
assignSeqNumsForReqs(txn, &put, &et)
_, pErr := tc.Sender().Send(ctx, ba)
if pErr != nil {
t.Fatalf("unexpected error: %s", pErr)
}
require.Nil(t, pErr)

// Replay the request. It initially tries to execute as a 1PC transaction,
// but will fail because of a WriteTooOldError that pushes the transaction.
// This forces the txn to execute normally, at which point it fails because
// the EndTxn is detected to be a duplicate.
_, pErr = tc.Sender().Send(ctx, ba)
if pErr == nil {
t.Fatalf("expected error, got nil")
}
require.NotNil(t, pErr)
require.Regexp(t,
`TransactionAbortedError\(ABORT_REASON_RECORD_ALREADY_WRITTEN_POSSIBLE_REPLAY\)`,
pErr)
Expand Down

0 comments on commit e7a2016

Please sign in to comment.