From a147f24d94b4ecb99162c0808e4a037f29166658 Mon Sep 17 00:00:00 2001 From: Ridwan Sharif Date: Mon, 10 Dec 2018 17:55:34 -0500 Subject: [PATCH 1/2] storage: allow transactions to run at a lower sequence Adds support to have transactions run at a lower sequence at a given key. It asserts the value it computes with the value written for the sequence in the intent history instead or returning a retry-able error. Release note: None --- pkg/roachpb/batch.go | 5 -- pkg/storage/client_split_test.go | 8 +- pkg/storage/engine/enginepb/mvcc.go | 26 ++++++ pkg/storage/engine/mvcc.go | 113 +++++++++++++++++++++--- pkg/storage/engine/mvcc_test.go | 132 ++++++++++++++++++++++++++-- pkg/storage/replica.go | 27 ------ pkg/storage/replica_test.go | 14 ++- 7 files changed, 266 insertions(+), 59 deletions(-) diff --git a/pkg/roachpb/batch.go b/pkg/roachpb/batch.go index faf0e88582a0..2e6ea0b7000d 100644 --- a/pkg/roachpb/batch.go +++ b/pkg/roachpb/batch.go @@ -123,11 +123,6 @@ func (ba *BatchRequest) IsTransactionWrite() bool { return ba.hasFlag(isTxnWrite) } -// IsRange returns true iff the BatchRequest contains range-based requests. -func (ba *BatchRequest) IsRange() bool { - return ba.hasFlag(isRange) -} - // IsUnsplittable returns true iff the BatchRequest an un-splittable request. func (ba *BatchRequest) IsUnsplittable() bool { return ba.hasFlag(isUnsplittable) diff --git a/pkg/storage/client_split_test.go b/pkg/storage/client_split_test.go index 93031634a02d..89e04a5fecbc 100644 --- a/pkg/storage/client_split_test.go +++ b/pkg/storage/client_split_test.go @@ -674,8 +674,8 @@ func TestStoreRangeSplitIdempotency(t *testing.T) { _, pErr := client.SendWrappedWith(context.Background(), store.TestSender(), roachpb.Header{ Txn: &lTxn, }, lIncArgs) - if _, ok := pErr.GetDetail().(*roachpb.TransactionRetryError); !ok { - t.Fatalf("unexpected idempotency failure: %v", pErr) + if pErr != nil { + t.Fatal(pErr) } // Send out the same increment copied from above (same txn/sequence), but @@ -684,8 +684,8 @@ func TestStoreRangeSplitIdempotency(t *testing.T) { RangeID: newRng.RangeID, Txn: &rTxn, }, rIncArgs) - if _, ok := pErr.GetDetail().(*roachpb.TransactionRetryError); !ok { - t.Fatalf("unexpected idempotency failure: %v", pErr) + if pErr != nil { + t.Fatal(pErr) } // Compare stats of split ranges to ensure they are non zero and diff --git a/pkg/storage/engine/enginepb/mvcc.go b/pkg/storage/engine/enginepb/mvcc.go index 3ac33fccc510..dc8fa217215c 100644 --- a/pkg/storage/engine/enginepb/mvcc.go +++ b/pkg/storage/engine/enginepb/mvcc.go @@ -14,6 +14,8 @@ package enginepb +import "sort" + // Short returns a prefix of the transaction's ID. func (t TxnMeta) Short() string { return t.ID.Short() @@ -135,3 +137,27 @@ func (meta *MVCCMetadata) AddToIntentHistory(seq int32, val []byte) { meta.IntentHistory = append(meta.IntentHistory, MVCCMetadata_SequencedIntent{Sequence: seq, Value: val}) } + +// GetPrevIntentSeq goes through the intent history and finds the previous +// intent's sequence number given the current sequence. +func (meta *MVCCMetadata) GetPrevIntentSeq(seq int32) (int32, bool) { + index := sort.Search(len(meta.IntentHistory), func(i int) bool { + return meta.IntentHistory[i].Sequence >= seq + }) + if index > 0 && index < len(meta.IntentHistory) { + return meta.IntentHistory[index-1].Sequence, true + } + return 0, false +} + +// GetIntentValue goes through the intent history and finds the value +// written at the sequence number. +func (meta *MVCCMetadata) GetIntentValue(seq int32) ([]byte, bool) { + index := sort.Search(len(meta.IntentHistory), func(i int) bool { + return meta.IntentHistory[i].Sequence >= seq + }) + if index < len(meta.IntentHistory) && meta.IntentHistory[index].Sequence == seq { + return meta.IntentHistory[index].Value, true + } + return nil, false +} diff --git a/pkg/storage/engine/mvcc.go b/pkg/storage/engine/mvcc.go index 9d6a03a6c80d..80d6d237e773 100644 --- a/pkg/storage/engine/mvcc.go +++ b/pkg/storage/engine/mvcc.go @@ -1140,6 +1140,105 @@ func maybeGetValue( return valueFn(exVal) } +// replayTransactionalWrite performs a transactional write under the assumption +// that the transactional write was already executed before. Essentially a replay. +// Since transactions should be idempotent, we must be particularly careful +// about writing an intent if it was already written. If the sequence of the +// transaction is at or below one found in `meta.Txn` then we should +// simply assert the value we're trying to add against the value that was +// previously written at that sequence. +// +// 1) Firstly, we find the value previously written as part of the same sequence. +// 2) We then figure out the value the transaction is trying to write (either the +// value itself or the valueFn applied to the right previous value). +// 3) We assert that the transactional write is idempotent. +// +// Ensure all intents are found and that the values are always accurate for +// transactional idempotency. +func replayTransactionalWrite( + ctx context.Context, + engine Writer, + iter Iterator, + meta *enginepb.MVCCMetadata, + ms *enginepb.MVCCStats, + key roachpb.Key, + timestamp hlc.Timestamp, + value []byte, + txn *roachpb.Transaction, + buf *putBuffer, + valueFn func(*roachpb.Value) ([]byte, error), +) error { + var found bool + var writtenValue []byte + var err error + metaKey := MakeMVCCMetadataKey(key) + if txn.Sequence == meta.Txn.Sequence { + // This is a special case. This is when the intent hasn't made it + // to the intent history yet. We must now assert the value written + // in the intent to the value we're trying to write. + getBuf := newGetBuffer() + defer getBuf.release() + getBuf.meta = buf.meta + var exVal *roachpb.Value + if exVal, _, _, err = mvccGetInternal( + ctx, iter, metaKey, timestamp, true /* consistent */, unsafeValue, txn, getBuf); err != nil { + return err + } + writtenValue = exVal.RawBytes + found = true + } else { + // Get the value from the intent history. + writtenValue, found = meta.GetIntentValue(txn.Sequence) + } + if !found { + return errors.Errorf("transaction %s with sequence %d missing an intent with lower sequence %d", + txn.ID, meta.Txn.Sequence, txn.Sequence) + } + + // If the valueFn is specified, we must apply it to the would-be value at the key. + if valueFn != nil { + prevSeq, prevValueWritten := meta.GetPrevIntentSeq(txn.Sequence) + if prevValueWritten { + // If the previous value was found in the IntentHistory, + // simply apply the value function to the historic value + // to get the would-be value. + prevVal, _ := meta.GetIntentValue(prevSeq) + value, err = valueFn(&roachpb.Value{RawBytes: prevVal}) + if err != nil { + return err + } + } else { + // If the previous value at the key wasn't written by this transaction, + // we must apply the value function to the last committed value on the key. + getBuf := newGetBuffer() + defer getBuf.release() + getBuf.meta = buf.meta + var exVal *roachpb.Value + var err error + + // Since we want the last committed value on the key, we must make + // an inconsistent read so we ignore our previous intents here. + if exVal, _, _, err = mvccGetInternal( + ctx, iter, metaKey, timestamp, false /* consistent */, unsafeValue, nil /* txn */, getBuf); err != nil { + return err + } + value, err = valueFn(exVal) + if err != nil { + return err + } + } + } + + // To ensure the transaction is idempotent, we must assert that the + // calculated value on this replay is the same as the one we've previously + // written. + if !bytes.Equal(value, writtenValue) { + return errors.Errorf("transaction %s with sequence %d has a different value %+v after recomputing from what was written: %+v", + txn.ID, txn.Sequence, value, writtenValue) + } + return nil +} + // mvccPutInternal adds a new timestamped value to the specified key. // If value is nil, creates a deletion tombstone value. valueFn is // an optional alternative to supplying value directly. It is passed @@ -1232,18 +1331,12 @@ func mvccPutInternal( } else if txn.Epoch < meta.Txn.Epoch { return errors.Errorf("put with epoch %d came after put with epoch %d in txn %s", txn.Epoch, meta.Txn.Epoch, txn.ID) - } else if txn.Epoch == meta.Txn.Epoch && - (txn.Sequence < meta.Txn.Sequence || - (txn.Sequence == meta.Txn.Sequence && - txn.DeprecatedBatchIndex <= meta.Txn.DeprecatedBatchIndex)) { - // Replay error if we encounter an older sequence number or - // the same (or earlier) batch index for the same sequence. - // TODO(ridwanmsharif, nvanbenschoten): Use the IntentHistory here - // to figure out what should happen here. - return roachpb.NewTransactionRetryError(roachpb.RETRY_POSSIBLE_REPLAY) + } else if txn.Epoch == meta.Txn.Epoch && txn.Sequence <= meta.Txn.Sequence { + return replayTransactionalWrite(ctx, engine, iter, meta, ms, key, timestamp, value, txn, buf, valueFn) } - // We need the previous value written here for the intent history. + // We're overwriting the intent that was present at this key, before we do + // that though - we must record the older intent in the IntentHistory. var prevIntentValBytes []byte getBuf := newGetBuffer() // Release the buffer after using the existing value. diff --git a/pkg/storage/engine/mvcc_test.go b/pkg/storage/engine/mvcc_test.go index 1a8b7b91c4e4..31bf7b5a9eb0 100644 --- a/pkg/storage/engine/mvcc_test.go +++ b/pkg/storage/engine/mvcc_test.go @@ -3302,11 +3302,11 @@ func TestMVCCWriteWithSequenceAndBatchIndex(t *testing.T) { batchIndex int32 expRetry bool }{ - {1, 0, true}, // old sequence old batch index - {1, 1, true}, // old sequence, same batch index - {1, 2, true}, // old sequence, new batch index - {2, 0, true}, // same sequence, old batch index - {2, 1, true}, // same sequence, same batch index + {1, 0, false}, // old sequence old batch index + {1, 1, false}, // old sequence, same batch index + {1, 2, false}, // old sequence, new batch index + {2, 0, false}, // same sequence, old batch index + {2, 1, false}, // same sequence, same batch index {2, 2, false}, // same sequence, new batch index {3, 0, false}, // new sequence, old batch index {3, 1, false}, // new sequence, same batch index @@ -4403,6 +4403,128 @@ func TestResolveIntentWithLowerEpoch(t *testing.T) { } } +// TestMVCCIdempotentTransactions verifies that trying to execute a transaction is +// idempotent. +func TestMVCCIdempotentTransactions(t *testing.T) { + defer leaktest.AfterTest(t)() + + ctx := context.Background() + engine := createTestEngine() + defer engine.Close() + + ts1 := hlc.Timestamp{WallTime: 1E9} + + key := roachpb.Key("a") + value := roachpb.MakeValueFromString("first value") + newValue := roachpb.MakeValueFromString("second value") + txn := &roachpb.Transaction{TxnMeta: enginepb.TxnMeta{ID: uuid.MakeV4(), Timestamp: ts1}} + txn.Status = roachpb.PENDING + + // Lay down an intent. + if err := MVCCPut(ctx, engine, nil, key, ts1, value, txn); err != nil { + t.Fatal(err) + } + + // Lay down an intent again with no problem because we're idempotent. + if err := MVCCPut(ctx, engine, nil, key, ts1, value, txn); err != nil { + t.Fatal(err) + } + + // Lay down an intent without increasing the sequence but with a different value. + if err := MVCCPut(ctx, engine, nil, key, ts1, newValue, txn); err != nil { + if !testutils.IsError(err, "has a different value") { + t.Fatal(err) + } + } else { + t.Fatalf("put should've failed as replay of a transaction yields a different value") + } + + // Lay down a second intent. + txn.Sequence++ + if err := MVCCPut(ctx, engine, nil, key, ts1, newValue, txn); err != nil { + t.Fatal(err) + } + + // Replay first intent without writing anything down. + txn.Sequence-- + if err := MVCCPut(ctx, engine, nil, key, ts1, value, txn); err != nil { + t.Fatal(err) + } + + // Check that the intent meta was as expected. + txn.Sequence++ + aggMeta := &enginepb.MVCCMetadata{ + Txn: &txn.TxnMeta, + Timestamp: hlc.LegacyTimestamp(ts1), + KeyBytes: mvccVersionTimestampSize, + ValBytes: int64(len(newValue.RawBytes)), + IntentHistory: []enginepb.MVCCMetadata_SequencedIntent{ + {Sequence: 0, Value: value.RawBytes}, + }, + } + metaKey := mvccKey(key) + meta := &enginepb.MVCCMetadata{} + ok, _, _, err := engine.GetProto(metaKey, meta) + if err != nil { + t.Fatal(err) + } + if !ok { + t.Fatal("intent should not be cleared") + } + if !meta.Equal(aggMeta) { + t.Errorf("expected metadata:\n%+v;\n got: \n%+v", aggMeta, meta) + } + txn.Sequence-- + // Lay down an intent without increasing the sequence but with a different value. + if err := MVCCPut(ctx, engine, nil, key, ts1, newValue, txn); err != nil { + if !testutils.IsError(err, "has a different value") { + t.Fatal(err) + } + } else { + t.Fatalf("put should've failed as replay of a transaction yields a different value") + } + + txn.Sequence-- + // Lay down an intent with a lower sequence number to see if it detects missing intents. + if err := MVCCPut(ctx, engine, nil, key, ts1, newValue, txn); err != nil { + if !testutils.IsError(err, "missing an intent") { + t.Fatal(err) + } + } else { + t.Fatalf("put should've failed as replay of a transaction yields a different value") + } + txn.Sequence += 3 + + // on a separate key, start an increment. + val, err := MVCCIncrement(ctx, engine, nil, testKey1, ts1, txn, 1) + if val != 1 || err != nil { + t.Fatalf("expected val=1 (got %d): %s", val, err) + } + // As long as the sequence in unchanged, replaying the increment doesn't + // increase the value. + for i := 0; i < 10; i++ { + val, err = MVCCIncrement(ctx, engine, nil, testKey1, ts1, txn, 1) + if val != 1 || err != nil { + t.Fatalf("expected val=1 (got %d): %s", val, err) + } + } + + // Increment again. + txn.Sequence++ + val, err = MVCCIncrement(ctx, engine, nil, testKey1, ts1, txn, 1) + if val != 2 || err != nil { + t.Fatalf("expected val=2 (got %d): %s", val, err) + } + txn.Sequence-- + // Replaying an older increment doesn't increase the value. + for i := 0; i < 10; i++ { + val, err = MVCCIncrement(ctx, engine, nil, testKey1, ts1, txn, 1) + if val != 1 || err != nil { + t.Fatalf("expected val=1 (got %d): %s", val, err) + } + } +} + // TestMVCCIntentHistory verifies that trying to write to a key that already was written // to, results in the history being recorded in the MVCCMetadata. func TestMVCCIntentHistory(t *testing.T) { diff --git a/pkg/storage/replica.go b/pkg/storage/replica.go index 8b17df5c9ab4..1a36f34305d7 100644 --- a/pkg/storage/replica.go +++ b/pkg/storage/replica.go @@ -3426,17 +3426,6 @@ func (r *Replica) evaluateProposal( // replication is not necessary. res.Local.Reply = br - // Assert that successful write requests result in intents. This is - // important for transactional pipelining and the parallel commit proposal - // because both use the presence of an intent to indicate that a write - // succeeded. This check may have false negatives but will never have false - // positives. - if br.Txn != nil && br.Txn.Status != roachpb.ABORTED { - if ba.IsTransactionWrite() && !ba.IsRange() && batch.Empty() { - log.Fatalf(ctx, "successful transaction point write batch %v resulted in no-op", ba) - } - } - // needConsensus determines if the result needs to be replicated and // proposed through Raft. This is necessary if at least one of the // following conditions is true: @@ -6388,22 +6377,6 @@ func evaluateBatch( // request. Each request will set their own sequence number on // the TxnMeta, which is stored as part of an intent. ba.Txn.Sequence = seqNum - } else { - // If the DisallowUnsequencedTransactionalWrites testing knob - // is set, we assert that all transaction writes has assigned - // Request-scoped sequence numbers. - if rec.EvalKnobs().DisallowUnsequencedTransactionalWrites { - if roachpb.IsTransactionWrite(args) { - log.Fatalf(ctx, "found unsequenced transactional request %v in %v", args, ba) - } - } - - // The Txn coordinator must not be setting sequence numbers on - // individual requests. Use the now-deprecated BatchIndex field. - // - // TODO(nvanbenschoten): remove this case and the explanation - // above in version 2.2. - ba.Txn.DeprecatedBatchIndex = int32(index) } } // Note that responses are populated even when an error is returned. diff --git a/pkg/storage/replica_test.go b/pkg/storage/replica_test.go index 364d0df52b6a..add21c21bca0 100644 --- a/pkg/storage/replica_test.go +++ b/pkg/storage/replica_test.go @@ -2891,9 +2891,10 @@ func TestReplicaAbortSpanReadError(t *testing.T) { } } -// TestReplicaAbortSpanStoredTxnRetryError verifies that if a cached -// entry is present, a transaction restart error is returned. -func TestReplicaAbortSpanStoredTxnRetryError(t *testing.T) { +// TestReplicaAbortSpanTxnIdempotency verifies that a TransactionAbortedError is +// found when a put is tried on an aborted txn. It further verifies transactions +// run successfully and in an idempotent manner when replaying the same requests. +func TestReplicaAbortSpanTxnIdempotency(t *testing.T) { defer leaktest.AfterTest(t)() tc := testContext{} stopper := stop.NewStopper() @@ -2940,11 +2941,8 @@ func TestReplicaAbortSpanStoredTxnRetryError(t *testing.T) { t.Fatal(pErr) } txn.Timestamp.Forward(txn.Timestamp.Add(10, 10)) // can't hurt - { - pErr := try() - if _, ok := pErr.GetDetail().(*roachpb.TransactionRetryError); !ok { - t.Fatal(pErr) - } + if pErr := try(); pErr != nil { + t.Fatal(pErr) } // Pretend we restarted by increasing the epoch. That's all that's needed. From e2459a29dd6a820f10fa15ad3f154cec001205cf Mon Sep 17 00:00:00 2001 From: Ridwan Sharif Date: Tue, 11 Dec 2018 16:45:50 -0500 Subject: [PATCH 2/2] storage: remove all references to DeprecatedBatchIndex Removes all references to the DeprecatedBatchIndex field. Release note: None --- .../storage/engine/enginepb/mvcc3.pb.cc | 43 +---- .../protos/storage/engine/enginepb/mvcc3.pb.h | 21 --- pkg/storage/below_raft_protos_test.go | 2 +- pkg/storage/engine/enginepb/mvcc3.pb.go | 174 +++++++----------- pkg/storage/engine/enginepb/mvcc3.proto | 15 +- pkg/storage/engine/mvcc.go | 3 + pkg/storage/engine/mvcc_test.go | 40 ++-- 7 files changed, 89 insertions(+), 209 deletions(-) diff --git a/c-deps/libroach/protos/storage/engine/enginepb/mvcc3.pb.cc b/c-deps/libroach/protos/storage/engine/enginepb/mvcc3.pb.cc index 633dfcdf6102..e7578c70ad17 100644 --- a/c-deps/libroach/protos/storage/engine/enginepb/mvcc3.pb.cc +++ b/c-deps/libroach/protos/storage/engine/enginepb/mvcc3.pb.cc @@ -275,7 +275,6 @@ const int TxnMeta::kEpochFieldNumber; const int TxnMeta::kTimestampFieldNumber; const int TxnMeta::kPriorityFieldNumber; const int TxnMeta::kSequenceFieldNumber; -const int TxnMeta::kDeprecatedBatchIndexFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 TxnMeta::TxnMeta() @@ -303,8 +302,8 @@ TxnMeta::TxnMeta(const TxnMeta& from) timestamp_ = NULL; } ::memcpy(&epoch_, &from.epoch_, - static_cast(reinterpret_cast(&deprecated_batch_index_) - - reinterpret_cast(&epoch_)) + sizeof(deprecated_batch_index_)); + static_cast(reinterpret_cast(&sequence_) - + reinterpret_cast(&epoch_)) + sizeof(sequence_)); // @@protoc_insertion_point(copy_constructor:cockroach.storage.engine.enginepb.TxnMeta) } @@ -312,8 +311,8 @@ void TxnMeta::SharedCtor() { id_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); key_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); ::memset(×tamp_, 0, static_cast( - reinterpret_cast(&deprecated_batch_index_) - - reinterpret_cast(×tamp_)) + sizeof(deprecated_batch_index_)); + reinterpret_cast(&sequence_) - + reinterpret_cast(×tamp_)) + sizeof(sequence_)); } TxnMeta::~TxnMeta() { @@ -349,8 +348,8 @@ void TxnMeta::Clear() { } timestamp_ = NULL; ::memset(&epoch_, 0, static_cast( - reinterpret_cast(&deprecated_batch_index_) - - reinterpret_cast(&epoch_)) + sizeof(deprecated_batch_index_)); + reinterpret_cast(&sequence_) - + reinterpret_cast(&epoch_)) + sizeof(sequence_)); _internal_metadata_.Clear(); } @@ -446,20 +445,6 @@ bool TxnMeta::MergePartialFromCodedStream( break; } - // int32 deprecated_batch_index = 8; - case 8: { - if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(64u /* 64 & 0xFF */)) { - - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, &deprecated_batch_index_))); - } else { - goto handle_unusual; - } - break; - } - default: { handle_unusual: if (tag == 0) { @@ -517,11 +502,6 @@ void TxnMeta::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteInt32(7, this->sequence(), output); } - // int32 deprecated_batch_index = 8; - if (this->deprecated_batch_index() != 0) { - ::google::protobuf::internal::WireFormatLite::WriteInt32(8, this->deprecated_batch_index(), output); - } - output->WriteRaw((::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()).data(), static_cast((::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()).size())); // @@protoc_insertion_point(serialize_end:cockroach.storage.engine.enginepb.TxnMeta) @@ -573,13 +553,6 @@ size_t TxnMeta::ByteSizeLong() const { this->sequence()); } - // int32 deprecated_batch_index = 8; - if (this->deprecated_batch_index() != 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->deprecated_batch_index()); - } - int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); SetCachedSize(cached_size); return total_size; @@ -617,9 +590,6 @@ void TxnMeta::MergeFrom(const TxnMeta& from) { if (from.sequence() != 0) { set_sequence(from.sequence()); } - if (from.deprecated_batch_index() != 0) { - set_deprecated_batch_index(from.deprecated_batch_index()); - } } void TxnMeta::CopyFrom(const TxnMeta& from) { @@ -647,7 +617,6 @@ void TxnMeta::InternalSwap(TxnMeta* other) { swap(epoch_, other->epoch_); swap(priority_, other->priority_); swap(sequence_, other->sequence_); - swap(deprecated_batch_index_, other->deprecated_batch_index_); _internal_metadata_.Swap(&other->_internal_metadata_); } diff --git a/c-deps/libroach/protos/storage/engine/enginepb/mvcc3.pb.h b/c-deps/libroach/protos/storage/engine/enginepb/mvcc3.pb.h index 7c383cd9e8cb..b4de3e41de2f 100644 --- a/c-deps/libroach/protos/storage/engine/enginepb/mvcc3.pb.h +++ b/c-deps/libroach/protos/storage/engine/enginepb/mvcc3.pb.h @@ -244,12 +244,6 @@ class TxnMeta : public ::google::protobuf::MessageLite /* @@protoc_insertion_poi ::google::protobuf::int32 sequence() const; void set_sequence(::google::protobuf::int32 value); - // int32 deprecated_batch_index = 8; - void clear_deprecated_batch_index(); - static const int kDeprecatedBatchIndexFieldNumber = 8; - ::google::protobuf::int32 deprecated_batch_index() const; - void set_deprecated_batch_index(::google::protobuf::int32 value); - // @@protoc_insertion_point(class_scope:cockroach.storage.engine.enginepb.TxnMeta) private: @@ -260,7 +254,6 @@ class TxnMeta : public ::google::protobuf::MessageLite /* @@protoc_insertion_poi ::google::protobuf::uint32 epoch_; ::google::protobuf::int32 priority_; ::google::protobuf::int32 sequence_; - ::google::protobuf::int32 deprecated_batch_index_; mutable ::google::protobuf::internal::CachedSize _cached_size_; friend struct ::protobuf_storage_2fengine_2fenginepb_2fmvcc3_2eproto::TableStruct; }; @@ -1779,20 +1772,6 @@ inline void TxnMeta::set_sequence(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:cockroach.storage.engine.enginepb.TxnMeta.sequence) } -// int32 deprecated_batch_index = 8; -inline void TxnMeta::clear_deprecated_batch_index() { - deprecated_batch_index_ = 0; -} -inline ::google::protobuf::int32 TxnMeta::deprecated_batch_index() const { - // @@protoc_insertion_point(field_get:cockroach.storage.engine.enginepb.TxnMeta.deprecated_batch_index) - return deprecated_batch_index_; -} -inline void TxnMeta::set_deprecated_batch_index(::google::protobuf::int32 value) { - - deprecated_batch_index_ = value; - // @@protoc_insertion_point(field_set:cockroach.storage.engine.enginepb.TxnMeta.deprecated_batch_index) -} - // ------------------------------------------------------------------- // MVCCStatsDelta diff --git a/pkg/storage/below_raft_protos_test.go b/pkg/storage/below_raft_protos_test.go index 6b4e21f0b862..c2e8f4833d54 100644 --- a/pkg/storage/below_raft_protos_test.go +++ b/pkg/storage/below_raft_protos_test.go @@ -63,7 +63,7 @@ var belowRaftGoldenProtos = map[reflect.Type]fixture{ return m }, emptySum: 7551962144604783939, - populatedSum: 10215960487899724343, + populatedSum: 17791546305376889937, }, reflect.TypeOf(&enginepb.RangeAppliedState{}): { populatedConstructor: func(r *rand.Rand) protoutil.Message { diff --git a/pkg/storage/engine/enginepb/mvcc3.pb.go b/pkg/storage/engine/enginepb/mvcc3.pb.go index 86a4abf374b3..137bab92c9f5 100644 --- a/pkg/storage/engine/enginepb/mvcc3.pb.go +++ b/pkg/storage/engine/enginepb/mvcc3.pb.go @@ -50,20 +50,6 @@ type TxnMeta struct { // last request. Used to prevent replay and out-of-order application // protection (by means of a transaction retry). Sequence int32 `protobuf:"varint,7,opt,name=sequence,proto3" json:"sequence,omitempty"` - // A zero-indexed sequence number indicating the index of a command - // within a batch. This disambiguate Raft replays of a batch from - // multiple commands in a batch which modify the same key. The field - // has now been deprecated because each request in a batch is now - // given its own sequence number. - // - // TODO(nvanbenschoten): Remove this field and its uses entirely - // in 2.2. This is safe because the field is only set on pending - // intents by transactions with 2.0 coordinators. 2.1 nodes need - // to be able to handle the field so they can interop with 2.0 nodes. - // However, 2.2 nodes will not, because all transactions started by - // 2.0 nodes will necessarily be abandoned for 2.2 nodes to join a - // cluster. - DeprecatedBatchIndex int32 `protobuf:"varint,8,opt,name=deprecated_batch_index,json=deprecatedBatchIndex,proto3" json:"deprecated_batch_index,omitempty"` } func (m *TxnMeta) Reset() { *m = TxnMeta{} } @@ -272,9 +258,6 @@ func (this *TxnMeta) Equal(that interface{}) bool { if this.Sequence != that1.Sequence { return false } - if this.DeprecatedBatchIndex != that1.DeprecatedBatchIndex { - return false - } return true } func (this *MVCCStatsDelta) Equal(that interface{}) bool { @@ -485,11 +468,6 @@ func (m *TxnMeta) MarshalTo(dAtA []byte) (int, error) { i++ i = encodeVarintMvcc3(dAtA, i, uint64(m.Sequence)) } - if m.DeprecatedBatchIndex != 0 { - dAtA[i] = 0x40 - i++ - i = encodeVarintMvcc3(dAtA, i, uint64(m.DeprecatedBatchIndex)) - } return i, nil } @@ -1002,10 +980,6 @@ func NewPopulatedTxnMeta(r randyMvcc3, easy bool) *TxnMeta { if r.Intn(2) == 0 { this.Sequence *= -1 } - this.DeprecatedBatchIndex = int32(r.Int31()) - if r.Intn(2) == 0 { - this.DeprecatedBatchIndex *= -1 - } if !easy && r.Intn(10) != 0 { } return this @@ -1174,9 +1148,6 @@ func (m *TxnMeta) Size() (n int) { if m.Sequence != 0 { n += 1 + sovMvcc3(uint64(m.Sequence)) } - if m.DeprecatedBatchIndex != 0 { - n += 1 + sovMvcc3(uint64(m.DeprecatedBatchIndex)) - } return n } @@ -1608,25 +1579,6 @@ func (m *TxnMeta) Unmarshal(dAtA []byte) error { break } } - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DeprecatedBatchIndex", wireType) - } - m.DeprecatedBatchIndex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMvcc3 - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.DeprecatedBatchIndex |= (int32(b) & 0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipMvcc3(dAtA[iNdEx:]) @@ -3334,69 +3286,67 @@ var ( func init() { proto.RegisterFile("storage/engine/enginepb/mvcc3.proto", fileDescriptorMvcc3) } var fileDescriptorMvcc3 = []byte{ - // 1013 bytes of a gzipped FileDescriptorProto + // 990 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0x4f, 0x6f, 0xe3, 0x44, - 0x14, 0xaf, 0xed, 0xa4, 0x4d, 0x26, 0x69, 0x49, 0x66, 0x2b, 0xb0, 0x8a, 0x36, 0xc9, 0x86, 0x4b, - 0x84, 0xc0, 0x41, 0xdb, 0x85, 0x43, 0x6f, 0xf9, 0x83, 0x50, 0x80, 0xa5, 0x60, 0xda, 0x5d, 0x09, - 0x84, 0xac, 0xc9, 0x78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55, 0x04, 0x15, 0xa5, 0xa7, 0xe3, 0x10, 0xf8, 0x0e, 0x28, 0x3b, 0xd8, 0x1a, 0xce, 0x19, 0x89, - 0x44, 0x00, 0x3f, 0xcf, 0x4a, 0x77, 0x6f, 0x71, 0x51, 0x07, 0x1f, 0xf4, 0xba, 0xdc, 0xdd, 0x71, - 0x88, 0x09, 0x1c, 0x9c, 0xae, 0x39, 0xa1, 0x4b, 0xa7, 0x44, 0xe6, 0x88, 0xb3, 0x86, 0x66, 0x91, - 0x7b, 0x44, 0x44, 0x06, 0x63, 0x3f, 0xf6, 0x98, 0x38, 0xf0, 0x04, 0xee, 0x71, 0x07, 0x7c, 0x1d, - 0x14, 0xc7, 0x64, 0x9e, 0x24, 0x6f, 0x0b, 0xb4, 0x30, 0x26, 0x73, 0x99, 0x9b, 0x80, 0x32, 0x75, - 0x27, 0x03, 0xb3, 0xcc, 0x29, 0x72, 0x93, 0xcc, 0x82, 0x04, 0xa7, 0xc8, 0xcd, 0x32, 0x39, 0x28, - 0x33, 0x8b, 0x19, 0x28, 0x33, 0x1f, 0x80, 0x72, 0x72, 0x04, 0x32, 0x19, 0x08, 0xbc, 0x24, 0x7d, - 0x32, 0x7f, 0x19, 0x22, 0x29, 0x4a, 0xab, 0x21, 0x59, 0xfd, 0x68, 0x1e, 0x25, 0x14, 0x65, 0x59, - 0x22, 0x9a, 0x47, 0x59, 0x7d, 0x0e, 0xca, 0xe4, 0xdd, 0x0c, 0x94, 0x99, 0x6f, 0x03, 0x88, 0x7d, - 0x8f, 0x21, 0xea, 0x45, 0x16, 0x89, 0x18, 0x9d, 0x20, 0x4e, 0xb1, 0xd7, 0x50, 0x5a, 0x05, 0xb3, - 0x9a, 0x22, 0xef, 0xa7, 0xc0, 0x51, 0x8e, 0x8b, 0xdf, 0xfc, 0x47, 0x03, 0xf7, 0xb8, 0xec, 0x9f, - 0x92, 0x30, 0xa2, 0x11, 0xdf, 0x86, 0x18, 0x80, 0x97, 0x4d, 0x7b, 0x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0x94, 0x2b, + 0x14, 0x2a, 0xc5, 0xc6, 0x5f, 0x10, 0xed, 0x3d, 0x7e, 0xd2, 0xed, 0x7e, 0xc6, 0x09, 0x8f, 0x7a, + 0xd4, 0xe5, 0x04, 0xbf, 0x81, 0xf6, 0x5d, 0x12, 0x71, 0x2b, 0x0e, 0x86, 0x84, 0x53, 0xcb, 0x23, + 0x9e, 0x1f, 0xc9, 0xd7, 0xaa, 0x98, 0xaf, 0x08, 0xe0, 0x4c, 0xfa, 0x3f, 0x16, 0x6e, 0x7c, 0x1f, + 0x21, 0xe6, 0x71, 0xea, 0x71, 0x8b, 0x38, 0x54, 0xd7, 0x64, 0x50, 0x51, 0x79, 0xda, 0x0e, 0xc5, + 0x6f, 0xa3, 0xb2, 0x63, 0x5b, 0x83, 0x39, 0xa7, 0x91, 0x0c, 0x10, 0xef, 0x53, 0xe9, 0xec, 0x2d, + 0x2e, 0x6b, 0xe8, 0x83, 0x6e, 0x47, 0xb8, 0xdb, 0x0e, 0x35, 0x91, 0x63, 0xa7, 0x67, 0x41, 0xe8, + 0xb2, 0x29, 0x55, 0x39, 0xf2, 0xed, 0xb0, 0x59, 0x14, 0x1e, 0x19, 0x91, 0xc1, 0xb6, 0x1f, 0x7b, + 0x5c, 0x3e, 0x60, 0x02, 0x77, 0x85, 0x03, 0xbf, 0x86, 0x8a, 0x63, 0x3a, 0x4f, 0x92, 0xb7, 0x25, + 0x5a, 0x18, 0xd3, 0xb9, 0xca, 0x4d, 0x40, 0x95, 0xba, 0x93, 0x81, 0x59, 0xe6, 0x94, 0xb8, 0x49, + 0x66, 0x41, 0x81, 0x53, 0xe2, 0x66, 0x99, 0x02, 0x54, 0x99, 0xc5, 0x0c, 0x54, 0x99, 0x0f, 0x50, + 0x39, 0x79, 0x02, 0x95, 0x8c, 0x24, 0x5e, 0x52, 0x3e, 0x95, 0xbf, 0x0c, 0x51, 0x14, 0xa5, 0xd5, + 0x90, 0xac, 0x7e, 0x34, 0x8f, 0x12, 0x8a, 0xb2, 0x2a, 0x11, 0xcd, 0xa3, 0xac, 0xbe, 0x00, 0x55, + 0xf2, 0x6e, 0x06, 0xaa, 0xcc, 0xb7, 0x10, 0xb6, 0x7d, 0x8f, 0x13, 0xe6, 0x45, 0x16, 0x8d, 0x38, + 0x9b, 0x10, 0x41, 0xb1, 0x57, 0x07, 0xcd, 0x82, 0xb9, 0x9f, 0x22, 0xef, 0xa7, 0xc0, 0x71, 0x4e, + 0x8c, 0x40, 0xe3, 0x6f, 0x88, 0xee, 0x09, 0xd9, 0x3f, 0xa1, 0x61, 0xc4, 0x22, 0x71, 0x0d, 0x39, + 0x00, 0xff, 0x37, 0xed, 0xe1, 0x66, 0xed, 0xe1, 0x46, 0xed, 0xe1, 0x26, 0xed, 0xe1, 0x26, 0xed, + 0xe1, 0x26, 0xed, 0xe1, 0x15, 0xda, 0xc3, 0xab, 0xb5, 0x87, 0x57, 0x68, 0x0f, 0x37, 0x69, 0x0f, + 0x6f, 0xae, 0x7d, 0xb6, 0x02, 0x1a, 0xcf, 0x01, 0xda, 0x37, 0x89, 0xe7, 0xd0, 0x76, 0x10, 0xb8, + 0x8c, 0x0e, 0x85, 0xfa, 0x14, 0xbf, 0x89, 0x70, 0x48, 0xbe, 0xe2, 0x16, 0x51, 0x4e, 0x8b, 0x79, + 0x43, 0x3a, 0x93, 0xf2, 0xe7, 0xcc, 0x8a, 0x40, 0x92, 0xe8, 0xbe, 0xf0, 0x63, 0x03, 0xdd, 0x73, + 0x29, 0x89, 0xe8, 0x0b, 0xe1, 0x9a, 0x0c, 0xdf, 0x97, 0xd0, 0x5a, 0xfc, 0x97, 0xa8, 0x14, 0x8a, + 0x92, 0x56, 0x24, 0x46, 0x4d, 0xce, 0x43, 0xe9, 0xe1, 0x7b, 0xc6, 0x95, 0xbb, 0xde, 0xf8, 0x97, + 0x41, 0x4d, 0xd6, 0x22, 0x92, 0x84, 0xd2, 0xb3, 0xd2, 0xdc, 0x37, 0xa8, 0x22, 0x52, 0x9e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fa, 0x20, 0xa6, 0xba, 0x9f, 0x32, 0xf1, 0xe7, 0x68, 0x37, 0xf9, 0xac, 0x25, 0xcc, + 0x4a, 0x8f, 0x77, 0x5f, 0x92, 0x79, 0x7d, 0xfe, 0xcd, 0x72, 0xbc, 0x62, 0x0b, 0x6e, 0x5b, 0x0e, + 0x5a, 0xca, 0x9d, 0xbb, 0x16, 0xf7, 0xfa, 0x90, 0x9a, 0x65, 0x7b, 0xc5, 0x16, 0x0f, 0x42, 0x84, + 0xcc, 0x29, 0x75, 0xfe, 0x5a, 0x0f, 0xb2, 0x36, 0x21, 0x66, 0x89, 0x2c, 0xcd, 0xe3, 0xdc, 0xc5, + 0x79, 0x0d, 0x74, 0xf4, 0x8b, 0xdf, 0xab, 0x5b, 0x17, 0x8b, 0x2a, 0xf8, 0x69, 0x51, 0x05, 0xbf, + 0x2c, 0xaa, 0xe0, 0xb7, 0x45, 0x15, 0x7c, 0xfb, 0x47, 0x75, 0x6b, 0xb0, 0x2d, 0xff, 0x75, 0x3e, + 0xfa, 0x27, 0x00, 0x00, 0xff, 0xff, 0xdc, 0xcb, 0x02, 0x8b, 0xb4, 0x0b, 0x00, 0x00, } diff --git a/pkg/storage/engine/enginepb/mvcc3.proto b/pkg/storage/engine/enginepb/mvcc3.proto index 9428599e7b80..043fb27cfd05 100644 --- a/pkg/storage/engine/enginepb/mvcc3.proto +++ b/pkg/storage/engine/enginepb/mvcc3.proto @@ -53,20 +53,7 @@ message TxnMeta { // last request. Used to prevent replay and out-of-order application // protection (by means of a transaction retry). int32 sequence = 7; - // A zero-indexed sequence number indicating the index of a command - // within a batch. This disambiguate Raft replays of a batch from - // multiple commands in a batch which modify the same key. The field - // has now been deprecated because each request in a batch is now - // given its own sequence number. - // - // TODO(nvanbenschoten): Remove this field and its uses entirely - // in 2.2. This is safe because the field is only set on pending - // intents by transactions with 2.0 coordinators. 2.1 nodes need - // to be able to handle the field so they can interop with 2.0 nodes. - // However, 2.2 nodes will not, because all transactions started by - // 2.0 nodes will necessarily be abandoned for 2.2 nodes to join a - // cluster. - int32 deprecated_batch_index = 8; + reserved 8; } // MVCCStatsDelta is convertible to MVCCStats, but uses signed variable width diff --git a/pkg/storage/engine/mvcc.go b/pkg/storage/engine/mvcc.go index 80d6d237e773..b709e4c95bb6 100644 --- a/pkg/storage/engine/mvcc.go +++ b/pkg/storage/engine/mvcc.go @@ -1332,6 +1332,9 @@ func mvccPutInternal( return errors.Errorf("put with epoch %d came after put with epoch %d in txn %s", txn.Epoch, meta.Txn.Epoch, txn.ID) } else if txn.Epoch == meta.Txn.Epoch && txn.Sequence <= meta.Txn.Sequence { + // The transaction has executed at this sequence before. This is merely a + // replay of the transactional write. Assert that all is in order and return + // early. return replayTransactionalWrite(ctx, engine, iter, meta, ms, key, timestamp, value, txn, buf, valueFn) } diff --git a/pkg/storage/engine/mvcc_test.go b/pkg/storage/engine/mvcc_test.go index 31bf7b5a9eb0..eea3e8a2c927 100644 --- a/pkg/storage/engine/mvcc_test.go +++ b/pkg/storage/engine/mvcc_test.go @@ -3286,11 +3286,10 @@ func TestMVCCReadWithOldEpoch(t *testing.T) { } } -// TestMVCCWriteWithSequenceAndBatchIndex verifies that retry errors +// TestMVCCWriteWithSequence verifies that no retry errors // are thrown in the event that earlier sequence numbers are -// encountered or if the same sequence and an earlier or same batch -// index. -func TestMVCCWriteWithSequenceAndBatchIndex(t *testing.T) { +// encountered. +func TestMVCCWriteWithSequence(t *testing.T) { defer leaktest.AfterTest(t)() ctx := context.Background() @@ -3298,39 +3297,32 @@ func TestMVCCWriteWithSequenceAndBatchIndex(t *testing.T) { defer engine.Close() testCases := []struct { - sequence int32 - batchIndex int32 - expRetry bool + sequence int32 + expectedErr string }{ - {1, 0, false}, // old sequence old batch index - {1, 1, false}, // old sequence, same batch index - {1, 2, false}, // old sequence, new batch index - {2, 0, false}, // same sequence, old batch index - {2, 1, false}, // same sequence, same batch index - {2, 2, false}, // same sequence, new batch index - {3, 0, false}, // new sequence, old batch index - {3, 1, false}, // new sequence, same batch index - {3, 2, false}, // new sequence, new batch index + {1, "missing an intent"}, // old sequence + {2, ""}, // same sequence + {3, ""}, // new sequence } ts := hlc.Timestamp{Logical: 1} for i, tc := range testCases { key := roachpb.Key(fmt.Sprintf("key-%d", i)) - // Start with sequence 2, batch index 1. + // Start with sequence 2. txn := *txn1 txn.Sequence = 2 - txn.DeprecatedBatchIndex = 1 if err := MVCCPut(ctx, engine, nil, key, ts, value1, &txn); err != nil { t.Fatal(err) } - txn.Sequence, txn.DeprecatedBatchIndex = tc.sequence, tc.batchIndex - err := MVCCPut(ctx, engine, nil, key, ts, value2, &txn) - _, ok := err.(*roachpb.TransactionRetryError) - if !tc.expRetry && ok { + txn.Sequence = tc.sequence + err := MVCCPut(ctx, engine, nil, key, ts, value1, &txn) + if tc.expectedErr != "" && err != nil { + if !testutils.IsError(err, tc.expectedErr) { + t.Fatalf("%d: unexpected error: %s", i, err) + } + } else if err != nil { t.Fatalf("%d: unexpected error: %s", i, err) - } else if ok != tc.expRetry { - t.Fatalf("%d: expected retry %t but got %s", i, tc.expRetry, err) } } }