Skip to content

Commit

Permalink
storage: remove obsolete code
Browse files Browse the repository at this point in the history
Remove InclusiveTimeBounds(), a vestige that used to be more complex for
backwards compatibility with 19.1 reasons but became obsolete when we
cleaned up the compatibility cruft.

Release note: None
  • Loading branch information
andreimatei committed Feb 10, 2020
1 parent 9e4da99 commit 86e87fe
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 45 deletions.
11 changes: 0 additions & 11 deletions pkg/roachpb/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -951,17 +951,6 @@ func (t *Transaction) BumpEpoch() {
t.Epoch++
}

// InclusiveTimeBounds returns start and end timestamps such that all intents written as
// part of this transaction have a timestamp in the interval [start, end].
func (t *Transaction) InclusiveTimeBounds() (hlc.Timestamp, hlc.Timestamp) {
min := t.MinTimestamp
max := t.WriteTimestamp
if min.IsEmpty() {
log.Fatalf(context.TODO(), "missing MinTimestamp on txn: %s", t)
}
return min, max
}

// Update ratchets priority, timestamp and original timestamp values (among
// others) for the transaction. If t.ID is empty, then the transaction is
// copied from o.
Expand Down
17 changes: 0 additions & 17 deletions pkg/roachpb/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,23 +396,6 @@ func TestTransactionBumpEpoch(t *testing.T) {
}
}

func TestTransactionInclusiveTimeBounds(t *testing.T) {
verify := func(txn Transaction, expMin, expMax hlc.Timestamp) {
if min, max := txn.InclusiveTimeBounds(); min != expMin || max != expMax {
t.Errorf("expected (%s-%s); got (%s-%s)", expMin, expMax, min, max)
}
}
origNow := makeTS(1, 1)
txn := MakeTransaction("test", Key("a"), 1, origNow, 0)
verify(txn, origNow, origNow)
txn.WriteTimestamp.Forward(makeTS(1, 2))
verify(txn, origNow, makeTS(1, 2))
txn.Restart(1, 1, makeTS(2, 1))
verify(txn, origNow, makeTS(2, 1))
txn.WriteTimestamp.Forward(makeTS(3, 1))
verify(txn, origNow, makeTS(3, 1))
}

// TestTransactionObservedTimestamp verifies that txn.{Get,Update}ObservedTimestamp work as
// advertised.
func TestTransactionObservedTimestamp(t *testing.T) {
Expand Down
16 changes: 1 addition & 15 deletions pkg/storage/batcheval/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,7 @@ 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.
//
// 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)
ok, minCommitTS, reason := rec.CanCreateTxnRecord(txn.ID, txn.Key, txn.MinTimestamp)
if !ok {
return roachpb.NewTransactionAbortedError(reason)
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/storage/intentresolver/intent_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,7 @@ func (ir *IntentResolver) cleanupFinishedTxnIntents(
}
}()
// Resolve intents.
min, _ := txn.InclusiveTimeBounds()
opts := ResolveOptions{Wait: true, Poison: poison, MinTimestamp: min}
opts := ResolveOptions{Wait: true, Poison: poison, MinTimestamp: txn.MinTimestamp}
if err := ir.ResolveIntents(ctx, intents, opts); err != nil {
return errors.Wrapf(err, "failed to resolve intents")
}
Expand Down

0 comments on commit 86e87fe

Please sign in to comment.