Skip to content

Commit

Permalink
roachpb: rename NoRefreshSpans -> CanCommitAtHigherTimestamp
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
andreimatei committed Dec 28, 2019
1 parent 6a7cfeb commit c2ffe71
Show file tree
Hide file tree
Showing 15 changed files with 656 additions and 644 deletions.
22 changes: 11 additions & 11 deletions c-deps/libroach/protos/roachpb/api.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions c-deps/libroach/protos/roachpb/api.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pkg/kv/dist_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ var errNo1PCTxn = roachpb.NewErrorf("cannot send 1PC txn to multiple ranges")

// splitBatchAndCheckForRefreshSpans splits the batch according to the
// canSplitET parameter and checks whether the final request is an
// EndTxn. If so, the EndTxnRequest.NoRefreshSpans
// EndTxn. If so, the EndTransactionRequest.CanCommitAtHigherTimestamp
// flag is reset to indicate whether earlier parts of the split may
// result in refresh spans.
func splitBatchAndCheckForRefreshSpans(
Expand All @@ -628,10 +628,10 @@ func splitBatchAndCheckForRefreshSpans(
parts := ba.Split(canSplitET)
// If the final part contains an EndTxn, we need to check
// whether earlier split parts contain any refresh spans and properly
// set the NoRefreshSpans flag on the end transaction.
// set the CanCommitAtHigherTimestamp flag on the end transaction.
lastPart := parts[len(parts)-1]
lastReq := lastPart[len(lastPart)-1].GetInner()
if et, ok := lastReq.(*roachpb.EndTxnRequest); ok && et.NoRefreshSpans {
if et, ok := lastReq.(*roachpb.EndTxnRequest); ok && et.CanCommitAtHigherTimestamp {
hasRefreshSpans := func() bool {
for _, part := range parts[:len(parts)-1] {
for _, req := range part {
Expand All @@ -644,7 +644,7 @@ func splitBatchAndCheckForRefreshSpans(
}()
if hasRefreshSpans {
etCopy := *et
etCopy.NoRefreshSpans = false
etCopy.CanCommitAtHigherTimestamp = false
lastPart = append([]roachpb.RequestUnion(nil), lastPart...)
lastPart[len(lastPart)-1].MustSetInner(&etCopy)
parts[len(parts)-1] = lastPart
Expand Down
4 changes: 2 additions & 2 deletions pkg/kv/txn_interceptor_committer.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (tc *txnCommitter) SendLocked(
// we transition to an explicitly committed transaction as soon as possible.
// This also has the side-effect of kicking off intent resolution.
mergedIntentSpans, _ := mergeIntoSpans(et.IntentSpans, et.InFlightWrites)
tc.makeTxnCommitExplicitAsync(ctx, br.Txn, mergedIntentSpans, et.NoRefreshSpans)
tc.makeTxnCommitExplicitAsync(ctx, br.Txn, mergedIntentSpans, et.CanCommitAtHigherTimestamp)

// Switch the status on the batch response's transaction to COMMITTED. No
// interceptor above this one in the stack should ever need to deal with
Expand Down Expand Up @@ -402,7 +402,7 @@ func makeTxnCommitExplicitLocked(
et := roachpb.EndTxnRequest{Commit: true}
et.Key = txn.Key
et.IntentSpans = intentSpans
et.NoRefreshSpans = noRefreshSpans
et.CanCommitAtHigherTimestamp = noRefreshSpans
ba.Add(&et)

_, pErr := s.SendLocked(ctx, ba)
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/txn_interceptor_span_refresher.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (sr *txnSpanRefresher) SendLocked(
if rArgs, hasET := ba.GetArg(roachpb.EndTxn); hasET {
et := rArgs.(*roachpb.EndTxnRequest)
if !sr.refreshInvalid && len(sr.refreshReads) == 0 && len(sr.refreshWrites) == 0 {
et.NoRefreshSpans = true
et.CanCommitAtHigherTimestamp = true
}
}

Expand Down
14 changes: 7 additions & 7 deletions pkg/kv/txn_interceptor_span_refresher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ func TestTxnSpanRefresherMaxTxnRefreshSpansBytes(t *testing.T) {
}

// TestTxnSpanRefresherAssignsNoRefreshSpans tests that the txnSpanRefresher
// assigns the NoRefreshSpans flag on EndTxn requests.
// assigns the CanCommitAtHigherTimestamp flag on EndTxn requests.
func TestTxnSpanRefresherAssignsNoRefreshSpans(t *testing.T) {
defer leaktest.AfterTest(t)()
ctx := context.Background()
Expand All @@ -403,15 +403,15 @@ func TestTxnSpanRefresherAssignsNoRefreshSpans(t *testing.T) {
// Set MaxTxnRefreshSpansBytes limit to 3 bytes.
MaxTxnRefreshSpansBytes.Override(&tsr.st.SV, 3)

// Send an EndTxn request. Should set NoRefreshSpans flag.
// Send an EndTxn request. Should set CanCommitAtHigherTimestamp flag.
var ba roachpb.BatchRequest
ba.Header = roachpb.Header{Txn: &txn}
ba.Add(&roachpb.EndTxnRequest{})

mockSender.MockSend(func(ba roachpb.BatchRequest) (*roachpb.BatchResponse, *roachpb.Error) {
require.Len(t, ba.Requests, 1)
require.IsType(t, &roachpb.EndTxnRequest{}, ba.Requests[0].GetInner())
require.True(t, ba.Requests[0].GetEndTxn().NoRefreshSpans)
require.True(t, ba.Requests[0].GetEndTxn().CanCommitAtHigherTimestamp)

br := ba.CreateReply()
br.Txn = ba.Txn
Expand All @@ -434,14 +434,14 @@ func TestTxnSpanRefresherAssignsNoRefreshSpans(t *testing.T) {
require.Equal(t, []roachpb.Span{scanArgs.Span()}, tsr.refreshReads)
require.False(t, tsr.refreshInvalid)

// Send another EndTxn request. Should NOT set NoRefreshSpans flag.
// Send another EndTxn request. Should NOT set CanCommitAtHigherTimestamp flag.
ba.Requests = nil
ba.Add(&roachpb.EndTxnRequest{})

mockSender.MockSend(func(ba roachpb.BatchRequest) (*roachpb.BatchResponse, *roachpb.Error) {
require.Len(t, ba.Requests, 1)
require.IsType(t, &roachpb.EndTxnRequest{}, ba.Requests[0].GetInner())
require.False(t, ba.Requests[0].GetEndTxn().NoRefreshSpans)
require.False(t, ba.Requests[0].GetEndTxn().CanCommitAtHigherTimestamp)

br = ba.CreateReply()
br.Txn = ba.Txn
Expand All @@ -464,14 +464,14 @@ func TestTxnSpanRefresherAssignsNoRefreshSpans(t *testing.T) {
require.Equal(t, []roachpb.Span(nil), tsr.refreshReads)
require.True(t, tsr.refreshInvalid)

// Send another EndTxn request. Still should NOT set NoRefreshSpans flag.
// Send another EndTxn request. Still should NOT set CanCommitAtHigherTimestamp flag.
ba.Requests = nil
ba.Add(&roachpb.EndTxnRequest{})

mockSender.MockSend(func(ba roachpb.BatchRequest) (*roachpb.BatchResponse, *roachpb.Error) {
require.Len(t, ba.Requests, 1)
require.IsType(t, &roachpb.EndTxnRequest{}, ba.Requests[0].GetInner())
require.False(t, ba.Requests[0].GetEndTxn().NoRefreshSpans)
require.False(t, ba.Requests[0].GetEndTxn().CanCommitAtHigherTimestamp)

br = ba.CreateReply()
br.Txn = ba.Txn
Expand Down
Loading

0 comments on commit c2ffe71

Please sign in to comment.