Skip to content

Commit

Permalink
storage: remain compatible with transactions missing their minimum ti…
Browse files Browse the repository at this point in the history
…mestamp

Fixes #39008.

This was missed in #38782. I must have been thinking about the behavior
we'll want to switch to in v20.1. Luckily, the issue was easily caught
by `tpcc/mixed-headroom/n5cpu16`.

Release note: None
  • Loading branch information
nvanbenschoten committed Jul 23, 2019
1 parent 4233a87 commit ebbe064
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/storage/batcheval/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,19 @@ func CanPushWithPriority(pusher, pushee *roachpb.Transaction) bool {
func CanCreateTxnRecord(rec EvalContext, txn *roachpb.Transaction) error {
// Provide the transaction's minimum timestamp. The transaction could not
// have written a transaction record previously with a timestamp below this.
txnMinTS := txn.MinTimestamp
if txnMinTS.IsEmpty() {
return errors.Errorf("no minimum transaction timestamp provided: %v", txn)
//
// We use InclusiveTimeBounds to remain backward compatible. However, if we
// don't need to worry about compatibility, we require the transaction to
// have a minimum timestamp field.
// TODO(nvanbenschoten): Replace this with txn.MinTimestamp in v20.1.
txnMinTS, _ := txn.InclusiveTimeBounds()
if util.RaceEnabled {
newTxnMinTS := txn.MinTimestamp
if newTxnMinTS.IsEmpty() {
return errors.Errorf("no minimum transaction timestamp provided: %v", txn)
} else if newTxnMinTS != txnMinTS {
return errors.Errorf("minimum transaction timestamp differs from lower time bound: %v", txn)
}
}
ok, minCommitTS, reason := rec.CanCreateTxnRecord(txn.ID, txn.Key, txnMinTS)
if !ok {
Expand Down

0 comments on commit ebbe064

Please sign in to comment.