Skip to content

Commit

Permalink
storage: fix flake in TestTxnRecordLifecycleTransitions
Browse files Browse the repository at this point in the history
Fixes #40537.

The test was specifically not restarting transactions at the push
timestamp (for the outdated epoch) cases, but the broken subtest
  TestTxnRecordLifecycleTransitions/push_transaction_(abort)_after_end_transaction_(stage)_with_outdated_epoch
was expecting its timestamp to be equal to the push timestamp.

Release note: None
  • Loading branch information
nvanbenschoten committed Sep 9, 2019
1 parent 82de988 commit b943d81
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions pkg/storage/replica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10551,14 +10551,14 @@ func TestTxnRecordLifecycleTransitions(t *testing.T) {
},
run: func(txn *roachpb.Transaction, now hlc.Timestamp) error {
clone := txn.Clone()
clone.Timestamp.Forward(now)
clone.Timestamp = clone.Timestamp.Add(0, 1)
pt := pushTxnArgs(pusher, clone, roachpb.PUSH_ABORT)
return sendWrappedWithErr(roachpb.Header{}, &pt)
},
expTxn: func(txn *roachpb.Transaction, pushTs hlc.Timestamp) roachpb.TransactionRecord {
record := txnWithStatus(roachpb.ABORTED)(txn, pushTs)
record.Timestamp.Forward(pushTs)
record.LastHeartbeat.Forward(pushTs)
record.Timestamp = record.Timestamp.Add(0, 1)
record.LastHeartbeat = record.LastHeartbeat.Add(0, 1)
record.Priority = pusher.Priority - 1
return record
},
Expand Down Expand Up @@ -10608,7 +10608,7 @@ func TestTxnRecordLifecycleTransitions(t *testing.T) {
expTxn: func(txn *roachpb.Transaction, pushTs hlc.Timestamp) roachpb.TransactionRecord {
record := txnWithStatus(roachpb.ABORTED)(txn, pushTs)
record.Epoch = txn.Epoch + 1
record.Timestamp.Forward(pushTs)
record.Timestamp = record.Timestamp.Add(0, 1)
record.LastHeartbeat = record.LastHeartbeat.Add(0, 1)
record.Priority = pusher.Priority - 1
return record
Expand Down Expand Up @@ -10642,7 +10642,7 @@ func TestTxnRecordLifecycleTransitions(t *testing.T) {
},
{
name: "heartbeat transaction with epoch bump after end transaction (abort)",
setup: func(txn *roachpb.Transaction, now hlc.Timestamp) error {
setup: func(txn *roachpb.Transaction, _ hlc.Timestamp) error {
et, etH := endTxnArgs(txn, false /* commit */)
return sendWrappedWithErr(etH, &et)
},
Expand All @@ -10652,7 +10652,7 @@ func TestTxnRecordLifecycleTransitions(t *testing.T) {
// threshold against this timestamp instead of its minimum
// timestamp.
clone := txn.Clone()
clone.Restart(-1, 0, now.Add(0, 1))
clone.Restart(-1, 0, now)
hb, hbH := heartbeatArgs(clone, now)
return sendWrappedWithErr(hbH, &hb)
},
Expand Down Expand Up @@ -11115,7 +11115,7 @@ func TestTxnRecordLifecycleTransitions(t *testing.T) {
},
{
name: "begin transaction after push transaction (abort)",
setup: func(txn *roachpb.Transaction, now hlc.Timestamp) error {
setup: func(txn *roachpb.Transaction, _ hlc.Timestamp) error {
pt := pushTxnArgs(pusher, txn, roachpb.PUSH_ABORT)
return sendWrappedWithErr(roachpb.Header{}, &pt)
},
Expand All @@ -11128,7 +11128,7 @@ func TestTxnRecordLifecycleTransitions(t *testing.T) {
},
{
name: "heartbeat transaction after push transaction (abort)",
setup: func(txn *roachpb.Transaction, now hlc.Timestamp) error {
setup: func(txn *roachpb.Transaction, _ hlc.Timestamp) error {
pt := pushTxnArgs(pusher, txn, roachpb.PUSH_ABORT)
return sendWrappedWithErr(roachpb.Header{}, &pt)
},
Expand All @@ -11141,7 +11141,7 @@ func TestTxnRecordLifecycleTransitions(t *testing.T) {
},
{
name: "heartbeat transaction with epoch bump after push transaction (abort)",
setup: func(txn *roachpb.Transaction, now hlc.Timestamp) error {
setup: func(txn *roachpb.Transaction, _ hlc.Timestamp) error {
pt := pushTxnArgs(pusher, txn, roachpb.PUSH_ABORT)
return sendWrappedWithErr(roachpb.Header{}, &pt)
},
Expand All @@ -11151,7 +11151,7 @@ func TestTxnRecordLifecycleTransitions(t *testing.T) {
// threshold against this timestamp instead of its minimum
// timestamp.
clone := txn.Clone()
clone.Restart(-1, 0, now.Add(0, 1))
clone.Restart(-1, 0, now)
hb, hbH := heartbeatArgs(clone, now)
return sendWrappedWithErr(hbH, &hb)
},
Expand All @@ -11160,7 +11160,7 @@ func TestTxnRecordLifecycleTransitions(t *testing.T) {
},
{
name: "end transaction (stage) after push transaction (abort)",
setup: func(txn *roachpb.Transaction, now hlc.Timestamp) error {
setup: func(txn *roachpb.Transaction, _ hlc.Timestamp) error {
pt := pushTxnArgs(pusher, txn, roachpb.PUSH_ABORT)
return sendWrappedWithErr(roachpb.Header{}, &pt)
},
Expand All @@ -11174,7 +11174,7 @@ func TestTxnRecordLifecycleTransitions(t *testing.T) {
},
{
name: "end transaction (abort) after push transaction (abort)",
setup: func(txn *roachpb.Transaction, now hlc.Timestamp) error {
setup: func(txn *roachpb.Transaction, _ hlc.Timestamp) error {
pt := pushTxnArgs(pusher, txn, roachpb.PUSH_ABORT)
return sendWrappedWithErr(roachpb.Header{}, &pt)
},
Expand All @@ -11188,7 +11188,7 @@ func TestTxnRecordLifecycleTransitions(t *testing.T) {
},
{
name: "end transaction (commit) after push transaction (abort)",
setup: func(txn *roachpb.Transaction, now hlc.Timestamp) error {
setup: func(txn *roachpb.Transaction, _ hlc.Timestamp) error {
pt := pushTxnArgs(pusher, txn, roachpb.PUSH_ABORT)
return sendWrappedWithErr(roachpb.Header{}, &pt)
},
Expand Down

0 comments on commit b943d81

Please sign in to comment.