From 17511f919b99c5f10b6206fa78ad767f1dc4479a Mon Sep 17 00:00:00 2001 From: Andrew Werner Date: Wed, 18 Sep 2019 22:02:35 +0000 Subject: [PATCH] storage: clean up preemptive snapshot when receiving replica ID as learner This commit adds an annotation to raft request messages to indicate that the sender believes the current replica is a learner. If the current replica on the recipient was created as a preemptive snapshot (it's initialized but not in the range) then we should remove that replica immediately. Release Justification: Release blocker, required for backwards compatibility. Release note: None --- pkg/storage/client_raft_test.go | 101 ++++++++++++- pkg/storage/raft.pb.go | 227 +++++++++++++++++------------ pkg/storage/raft.proto | 10 ++ pkg/storage/replica_init.go | 8 +- pkg/storage/replica_raft.go | 25 +++- pkg/storage/store.go | 112 ++++++++------ pkg/storage/store_snapshot.go | 4 + pkg/storage/store_snapshot_test.go | 2 +- pkg/storage/stores_test.go | 17 ++- 9 files changed, 352 insertions(+), 154 deletions(-) diff --git a/pkg/storage/client_raft_test.go b/pkg/storage/client_raft_test.go index 30ccfec80847..5e9209a7fd83 100644 --- a/pkg/storage/client_raft_test.go +++ b/pkg/storage/client_raft_test.go @@ -18,6 +18,7 @@ import ( "math/rand" "reflect" "runtime" + "strings" "sync" "sync/atomic" "testing" @@ -30,6 +31,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/rpc" "github.com/cockroachdb/cockroach/pkg/rpc/nodedialer" + "github.com/cockroachdb/cockroach/pkg/server" "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/storage" "github.com/cockroachdb/cockroach/pkg/storage/engine" @@ -37,6 +39,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/storage/storagebase" "github.com/cockroachdb/cockroach/pkg/storage/storagepb" "github.com/cockroachdb/cockroach/pkg/testutils" + "github.com/cockroachdb/cockroach/pkg/testutils/testcluster" "github.com/cockroachdb/cockroach/pkg/util" "github.com/cockroachdb/cockroach/pkg/util/ctxgroup" "github.com/cockroachdb/cockroach/pkg/util/hlc" @@ -5064,7 +5067,6 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) { mtc.waitForValues(keyB, []int64{0, curB, curB}) } - // Restart store 0 so that it forgets about the newer replicaID. mtc.stopStore(0) mtc.restartStore(0) @@ -5088,3 +5090,100 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) { mtc.waitForValues(keyB, []int64{curB, curB, curB}) }) } + +// TestUpgradeFromPreemptiveSnapshot exercises scenarios where a store has +// received a preemptive snapshot for a range and then later is added to the +// range as a learner. +// +// In these cases it is critical that the store destroy the replica created by +// the preemptive snapshot otherwise the replica may try to catch up across +// commands which are not safe (namely merges). +// Before learner replicas we would not add a store to a range until we had +// successfully sent a preemptive snapshot that contained the range descriptor +// used in the change replicas request. +func TestUpgradeFromPreemptiveSnapshot(t *testing.T) { + defer leaktest.AfterTest(t)() + ctx := context.Background() + var proposalFilter atomic.Value + noopProposalFilter := storagebase.ReplicaProposalFilter(func(storagebase.ProposalFilterArgs) *roachpb.Error { + return nil + }) + blockAllProposalFilter := storagebase.ReplicaProposalFilter(func(args storagebase.ProposalFilterArgs) *roachpb.Error { + return roachpb.NewError(errors.Errorf("boom")) + }) + setupTestCluster := func(t *testing.T) *testcluster.TestCluster { + proposalFilter.Store(noopProposalFilter) + tcArgs := base.TestClusterArgs{ + ReplicationMode: base.ReplicationManual, + ServerArgs: base.TestServerArgs{ + Knobs: base.TestingKnobs{ + Store: &storage.StoreTestingKnobs{ + BootstrapVersion: &cluster.ClusterVersion{ + Version: cluster.VersionByKey(cluster.Version19_1), + }, + DisableLoadBasedSplitting: true, + DisableMergeQueue: true, + TestingProposalFilter: func(args storagebase.ProposalFilterArgs) *roachpb.Error { + return proposalFilter.Load().(storagebase.ReplicaProposalFilter)(args) + }, + }, + Server: &server.TestingKnobs{ + DisableAutomaticVersionUpgrade: 1, + }, + }, + }, + } + return testcluster.StartTestCluster(t, 4, tcArgs) + } + t.Run("add after preemptive snapshot before merge", func(t *testing.T) { + tc := setupTestCluster(t) + defer tc.Stopper().Stop(ctx) + scratchStartKey := tc.ScratchRange(t) + keyA := append(scratchStartKey[:len(scratchStartKey):len(scratchStartKey)], 'a') + + // Set up a scratch range on n1, n2, and n3. + tc.AddReplicasOrFatal(t, scratchStartKey, tc.Target(1), tc.Target(2)) + // Split that range. + err := tc.Server(0).DB().AdminSplit(ctx, scratchStartKey, keyA, hlc.Timestamp{}) + require.NoError(t, err) + require.NoError(t, tc.WaitForSplitAndInitialization(keyA)) + require.NoError(t, tc.WaitForVoters(scratchStartKey, tc.Target(1), tc.Target(2))) + require.NoError(t, tc.WaitForVoters(keyA, tc.Target(1), tc.Target(2))) + // Prevent n4 from successfully being added by blocking the proposal. + proposalFilter.Store(blockAllProposalFilter) + // Issue the add to send a preemptive snapshot. + _, err = tc.AddReplicas(scratchStartKey, tc.Target(3)) + // Ensure that the add failed with our proposal filter error. + require.True(t, testutils.IsError(err, "boom"), err) + + // Reset the filter. + proposalFilter.Store(noopProposalFilter) + // Merge the range back together. + err = tc.Server(0).DB().AdminMerge(ctx, scratchStartKey) + require.NoError(t, err) + // Upgrade the cluster to use learners. + _, err = tc.ServerConn(0). + Exec("SET CLUSTER SETTING version = crdb_internal.node_executable_version();") + require.NoError(t, err) + // We need to ensure that all nodes have received the cluster setting change. + + // Successfully add node 4, this used to fail as node 4 would attempt to + // catch up from the preemptive snapshot across the merge and would not + // accept the preemptive snapshot if we have not heard about the cluster + // setting yet. + var desc roachpb.RangeDescriptor + // Use a SucceedsSoon to deal with propagating the cluster setting. + testutils.SucceedsSoon(t, func() (err error) { + desc, err = tc.AddReplicas(scratchStartKey, tc.Target(3)) + if err != nil && + !strings.Contains(err.Error(), "remote couldn't accept PREEMPTIVE snapshot") { + t.Fatal(err) + } + return err + }) + // Transfer the lease to node 4 and remove node 0 to ensure that it really + // is a part of the range. + require.NoError(t, tc.TransferRangeLease(desc, tc.Target(3))) + tc.RemoveReplicasOrFatal(t, scratchStartKey, tc.Target(0)) + }) +} diff --git a/pkg/storage/raft.pb.go b/pkg/storage/raft.pb.go index 97b93abcba9a..05c6e6ce9c58 100644 --- a/pkg/storage/raft.pb.go +++ b/pkg/storage/raft.pb.go @@ -70,7 +70,7 @@ func (x *SnapshotRequest_Priority) UnmarshalJSON(data []byte) error { return nil } func (SnapshotRequest_Priority) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_raft_d6a64da2f1251cf6, []int{5, 0} + return fileDescriptor_raft_c419318fe988e310, []int{5, 0} } type SnapshotRequest_Strategy int32 @@ -107,7 +107,7 @@ func (x *SnapshotRequest_Strategy) UnmarshalJSON(data []byte) error { return nil } func (SnapshotRequest_Strategy) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_raft_d6a64da2f1251cf6, []int{5, 1} + return fileDescriptor_raft_c419318fe988e310, []int{5, 1} } type SnapshotRequest_Type int32 @@ -146,7 +146,7 @@ func (x *SnapshotRequest_Type) UnmarshalJSON(data []byte) error { return nil } func (SnapshotRequest_Type) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_raft_d6a64da2f1251cf6, []int{5, 2} + return fileDescriptor_raft_c419318fe988e310, []int{5, 2} } type SnapshotResponse_Status int32 @@ -191,7 +191,7 @@ func (x *SnapshotResponse_Status) UnmarshalJSON(data []byte) error { return nil } func (SnapshotResponse_Status) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_raft_d6a64da2f1251cf6, []int{6, 0} + return fileDescriptor_raft_c419318fe988e310, []int{6, 0} } // RaftHeartbeat is a request that contains the barebones information for a @@ -205,13 +205,22 @@ type RaftHeartbeat struct { Term uint64 `protobuf:"varint,4,opt,name=term" json:"term"` Commit uint64 `protobuf:"varint,5,opt,name=commit" json:"commit"` Quiesce bool `protobuf:"varint,6,opt,name=quiesce" json:"quiesce"` + // ToIsLearner was added in v19.2 to aid in the transition from preemptive + // snapshots to learner replicas. If a Replica learns its ID from a message + // which indicates that it is a learner and it is not currently a part of the + // range (due to being from a preemptive snapshot) then it must delete all of + // its data. + // + // TODO(ajwerner): remove in 20.2 once we ensure that preemptive snapshots can + // no longer be present and that we're never talking to a 19.2 node. + ToIsLearner bool `protobuf:"varint,7,opt,name=to_is_learner,json=toIsLearner" json:"to_is_learner"` } func (m *RaftHeartbeat) Reset() { *m = RaftHeartbeat{} } func (m *RaftHeartbeat) String() string { return proto.CompactTextString(m) } func (*RaftHeartbeat) ProtoMessage() {} func (*RaftHeartbeat) Descriptor() ([]byte, []int) { - return fileDescriptor_raft_d6a64da2f1251cf6, []int{0} + return fileDescriptor_raft_c419318fe988e310, []int{0} } func (m *RaftHeartbeat) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -267,7 +276,7 @@ func (m *RaftMessageRequest) Reset() { *m = RaftMessageRequest{} } func (m *RaftMessageRequest) String() string { return proto.CompactTextString(m) } func (*RaftMessageRequest) ProtoMessage() {} func (*RaftMessageRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_raft_d6a64da2f1251cf6, []int{1} + return fileDescriptor_raft_c419318fe988e310, []int{1} } func (m *RaftMessageRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -300,7 +309,7 @@ func (m *RaftMessageRequestBatch) Reset() { *m = RaftMessageRequestBatch func (m *RaftMessageRequestBatch) String() string { return proto.CompactTextString(m) } func (*RaftMessageRequestBatch) ProtoMessage() {} func (*RaftMessageRequestBatch) Descriptor() ([]byte, []int) { - return fileDescriptor_raft_d6a64da2f1251cf6, []int{2} + return fileDescriptor_raft_c419318fe988e310, []int{2} } func (m *RaftMessageRequestBatch) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -333,7 +342,7 @@ func (m *RaftMessageResponseUnion) Reset() { *m = RaftMessageResponseUni func (m *RaftMessageResponseUnion) String() string { return proto.CompactTextString(m) } func (*RaftMessageResponseUnion) ProtoMessage() {} func (*RaftMessageResponseUnion) Descriptor() ([]byte, []int) { - return fileDescriptor_raft_d6a64da2f1251cf6, []int{3} + return fileDescriptor_raft_c419318fe988e310, []int{3} } func (m *RaftMessageResponseUnion) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -376,7 +385,7 @@ func (m *RaftMessageResponse) Reset() { *m = RaftMessageResponse{} } func (m *RaftMessageResponse) String() string { return proto.CompactTextString(m) } func (*RaftMessageResponse) ProtoMessage() {} func (*RaftMessageResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_raft_d6a64da2f1251cf6, []int{4} + return fileDescriptor_raft_c419318fe988e310, []int{4} } func (m *RaftMessageResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -417,7 +426,7 @@ func (m *SnapshotRequest) Reset() { *m = SnapshotRequest{} } func (m *SnapshotRequest) String() string { return proto.CompactTextString(m) } func (*SnapshotRequest) ProtoMessage() {} func (*SnapshotRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_raft_d6a64da2f1251cf6, []int{5} + return fileDescriptor_raft_c419318fe988e310, []int{5} } func (m *SnapshotRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -479,7 +488,7 @@ func (m *SnapshotRequest_Header) Reset() { *m = SnapshotRequest_Header{} func (m *SnapshotRequest_Header) String() string { return proto.CompactTextString(m) } func (*SnapshotRequest_Header) ProtoMessage() {} func (*SnapshotRequest_Header) Descriptor() ([]byte, []int) { - return fileDescriptor_raft_d6a64da2f1251cf6, []int{5, 0} + return fileDescriptor_raft_c419318fe988e310, []int{5, 0} } func (m *SnapshotRequest_Header) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -513,7 +522,7 @@ func (m *SnapshotResponse) Reset() { *m = SnapshotResponse{} } func (m *SnapshotResponse) String() string { return proto.CompactTextString(m) } func (*SnapshotResponse) ProtoMessage() {} func (*SnapshotResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_raft_d6a64da2f1251cf6, []int{6} + return fileDescriptor_raft_c419318fe988e310, []int{6} } func (m *SnapshotResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -550,7 +559,7 @@ func (m *ConfChangeContext) Reset() { *m = ConfChangeContext{} } func (m *ConfChangeContext) String() string { return proto.CompactTextString(m) } func (*ConfChangeContext) ProtoMessage() {} func (*ConfChangeContext) Descriptor() ([]byte, []int) { - return fileDescriptor_raft_d6a64da2f1251cf6, []int{7} + return fileDescriptor_raft_c419318fe988e310, []int{7} } func (m *ConfChangeContext) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -798,6 +807,14 @@ func (m *RaftHeartbeat) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0 } i++ + dAtA[i] = 0x38 + i++ + if m.ToIsLearner { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ return i, nil } @@ -1173,6 +1190,7 @@ func (m *RaftHeartbeat) Size() (n int) { n += 1 + sovRaft(uint64(m.Term)) n += 1 + sovRaft(uint64(m.Commit)) n += 2 + n += 2 return n } @@ -1496,6 +1514,26 @@ func (m *RaftHeartbeat) Unmarshal(dAtA []byte) error { } } m.Quiesce = bool(v != 0) + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ToIsLearner", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRaft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.ToIsLearner = bool(v != 0) default: iNdEx = preIndex skippy, err := skipRaft(dAtA[iNdEx:]) @@ -2814,85 +2852,86 @@ var ( ErrIntOverflowRaft = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("storage/raft.proto", fileDescriptor_raft_d6a64da2f1251cf6) } - -var fileDescriptor_raft_d6a64da2f1251cf6 = []byte{ - // 1224 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x56, 0x5f, 0x6f, 0xdb, 0x54, - 0x14, 0x8f, 0x1b, 0x27, 0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x13, 0x31, 0x63, - 0xde, 0x0b, 0x8c, 0xee, 0x40, 0xce, 0x75, 0xfc, 0xde, 0x00, 0xbb, 0x63, 0xcf, 0xc7, 0x6f, 0x7d, - 0x30, 0xb8, 0x8e, 0xdf, 0x12, 0x72, 0x64, 0x41, 0x8a, 0x1f, 0xf0, 0x7c, 0x39, 0x2d, 0x4f, 0xee, - 0xfc, 0x2a, 0x10, 0xb7, 0xc2, 0x01, 0x03, 0xc4, 0xc1, 0x73, 0x34, 0xda, 0x05, 0x2d, 0x08, 0x3d, - 0x12, 0x7a, 0x74, 0xc6, 0x0f, 0x93, 0xd5, 0xa5, 0x4d, 0x70, 0xb1, 0x4c, 0x1d, 0x09, 0x89, 0x07, - 0x37, 0xa6, 0x60, 0x74, 0x11, 0x0d, 0x1d, 0x8a, 0x87, 0x33, 0x23, 0x73, 0x65, 0xba, 0x03, 0x09, - 0x89, 0xe9, 0x62, 0x0a, 0xb4, 0x09, 0xb7, 0xa6, 0xbe, 0xec, 0x74, 0x8a, 0x07, 0x3d, 0x1a, 0x4e, - 0x7d, 0xf1, 0x24, 0x62, 0xd7, 0x16, 0x92, 0x53, 0x5c, 0xb4, 0xec, 0xc6, 0x86, 0x3c, 0x64, 0x54, - 0x07, 0x95, 0xce, 0x02, 0x6c, 0x64, 0xf9, 0x27, 0x7d, 0x72, 0x85, 0x4f, 0xea, 0xce, 0x02, 0x3c, - 0x3f, 0x92, 0x67, 0x01, 0x7e, 0xac, 0x6a, 0x8a, 0xbe, 0x62, 0x3e, 0x04, 0x2d, 0x8e, 0x1d, 0xe5, - 0x20, 0xf3, 0x64, 0x6f, 0x7b, 0x6f, 0xff, 0xeb, 0x3d, 0x3d, 0x81, 0xf2, 0xa0, 0xd9, 0x56, 0x73, - 0xff, 0xd0, 0xb2, 0xbf, 0xd1, 0x15, 0x54, 0x80, 0xac, 0x6d, 0x35, 0xea, 0x3b, 0xf5, 0xbd, 0xa6, - 0xa5, 0xaf, 0x98, 0x06, 0x68, 0x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0x11, 0x97, 0xc5, 0xbc, - 0x1d, 0xbf, 0x6e, 0xbc, 0x52, 0x20, 0xbb, 0x3b, 0x1d, 0x53, 0x8f, 0xcd, 0x29, 0x1a, 0x83, 0xbe, - 0x30, 0xaf, 0x62, 0x75, 0xdc, 0xbf, 0xda, 0x50, 0x33, 0xdb, 0xe2, 0xdd, 0xab, 0xed, 0x47, 0x33, - 0x51, 0x51, 0x1e, 0x28, 0xe8, 0x29, 0xe4, 0x99, 0x32, 0x4e, 0x3d, 0x32, 0xdf, 0xdd, 0x76, 0xc5, - 0xdb, 0x57, 0xa8, 0x9d, 0xa0, 0x6f, 0xdc, 0x3b, 0xf9, 0xa3, 0x94, 0x38, 0x39, 0x2b, 0x29, 0x2f, - 0xcf, 0x4a, 0xca, 0xab, 0xb3, 0x92, 0xf2, 0xfb, 0x59, 0x49, 0xf9, 0xe1, 0x75, 0x29, 0xf1, 0xf2, - 0x75, 0x29, 0xf1, 0xea, 0x75, 0x29, 0xf1, 0x6d, 0x46, 0x32, 0xfc, 0x15, 0x00, 0x00, 0xff, 0xff, - 0x38, 0x31, 0xfb, 0x9d, 0x72, 0x0c, 0x00, 0x00, +func init() { proto.RegisterFile("storage/raft.proto", fileDescriptor_raft_c419318fe988e310) } + +var fileDescriptor_raft_c419318fe988e310 = []byte{ + // 1243 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x56, 0x4b, 0x6f, 0xdb, 0x46, + 0x10, 0x16, 0x2d, 0x5a, 0x8f, 0x91, 0x64, 0x33, 0xdb, 0xa0, 0x25, 0xd4, 0x54, 0x16, 0x94, 0x26, + 0x55, 0x52, 0x54, 0x4a, 0x8d, 0xb4, 0x87, 0xde, 0xf4, 0xa0, 0x63, 0xc5, 0x2f, 0x81, 0x56, 0x5c, + 0xb4, 0x40, 0x20, 0x50, 0xd4, 0x5a, 0x22, 0x2c, 0x71, 0x99, 0xe5, 0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 0x83, 0xa3, 0x51, 0x5d, 0x65, 0x51, 0x53, 0x7e, 0x76, 0x5a, 0x00, 0x77, 0x86, 0xe8, + 0x07, 0x58, 0x3d, 0xa4, 0x64, 0xda, 0xa7, 0x38, 0x98, 0x78, 0xae, 0xc3, 0x43, 0x2d, 0x95, 0xb5, + 0x6a, 0xa1, 0xb9, 0xa7, 0x42, 0x15, 0x36, 0x28, 0x99, 0xda, 0x52, 0x2b, 0x02, 0x7e, 0x7d, 0xbd, + 0x80, 0x91, 0xa7, 0x5d, 0x38, 0x8c, 0x01, 0x0d, 0xd1, 0x33, 0x28, 0x30, 0x12, 0x0f, 0x9b, 0x14, + 0x61, 0x77, 0x54, 0xd8, 0x5c, 0x8f, 0xfc, 0x1b, 0x41, 0x73, 0x8c, 0x9c, 0x85, 0x34, 0x41, 0x67, + 0x98, 0x4e, 0x4d, 0x5d, 0xd4, 0x52, 0xe7, 0x91, 0x6c, 0x21, 0x41, 0xb7, 0x20, 0xe5, 0x92, 0xe9, + 0xd4, 0x63, 0xe6, 0x72, 0x4c, 0xa7, 0x64, 0xa8, 0x04, 0xe9, 0x67, 0x33, 0x0f, 0x87, 0x2e, 0x36, + 0x53, 0x65, 0xad, 0x9a, 0x51, 0xea, 0x48, 0x88, 0xaa, 0x22, 0x15, 0x2f, 0xec, 0x4f, 0xb0, 0x43, + 0x7d, 0x4c, 0xcd, 0x74, 0xcc, 0x2a, 0xc7, 0x48, 0x27, 0xdc, 0x96, 0x8a, 0xca, 0x6f, 0x3a, 0x20, + 0xce, 0xf1, 0x0e, 0x0e, 0x43, 0x67, 0x84, 0x6d, 0xfc, 0x6c, 0x86, 0xc3, 0xff, 0x86, 0xe8, 0x1d, + 0xc8, 0xc7, 0x89, 0x16, 0x2c, 0xe7, 0xd6, 0x3f, 0xad, 0x9d, 0x0d, 0xc2, 0xb9, 0xea, 0xb5, 0x71, + 0xe8, 0x52, 0x2f, 0x60, 0x84, 0x46, 0x99, 0xc4, 0x08, 0x44, 0x1d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9a, 0x80, 0x11, 0x9b, 0x57, 0xb9, 0x3a, 0xee, 0x5f, 0x6d, 0xa8, 0xb9, 0x6d, 0xf1, 0xee, 0xd5, + 0xf6, 0x63, 0x25, 0x51, 0xd5, 0x1e, 0x68, 0xe8, 0x29, 0xe4, 0xb9, 0x32, 0x2a, 0x3d, 0xaa, 0xbc, + 0xbf, 0xed, 0x8a, 0xb7, 0xaf, 0xc0, 0x9d, 0x84, 0x6f, 0xde, 0x3b, 0x7e, 0x5d, 0x4a, 0x1c, 0x9f, + 0x96, 0xb4, 0x97, 0xa7, 0x25, 0xed, 0xd5, 0x69, 0x49, 0xfb, 0xe3, 0xb4, 0xa4, 0xfd, 0xf4, 0xa6, + 0x94, 0x78, 0xf9, 0xa6, 0x94, 0x78, 0xf5, 0xa6, 0x94, 0xf8, 0x3e, 0xad, 0x10, 0xfe, 0x0a, 0x00, + 0x00, 0xff, 0xff, 0xd1, 0xe2, 0x72, 0x64, 0x9c, 0x0c, 0x00, 0x00, } diff --git a/pkg/storage/raft.proto b/pkg/storage/raft.proto index b008a8cada9f..3cad2bc76021 100644 --- a/pkg/storage/raft.proto +++ b/pkg/storage/raft.proto @@ -35,6 +35,16 @@ message RaftHeartbeat { optional uint64 term = 4 [(gogoproto.nullable) = false]; optional uint64 commit = 5 [(gogoproto.nullable) = false]; optional bool quiesce = 6 [(gogoproto.nullable) = false]; + + // ToIsLearner was added in v19.2 to aid in the transition from preemptive + // snapshots to learner replicas. If a Replica learns its ID from a message + // which indicates that it is a learner and it is not currently a part of the + // range (due to being from a preemptive snapshot) then it must delete all of + // its data. + // + // TODO(ajwerner): remove in 20.2 once we ensure that preemptive snapshots can + // no longer be present and that we're never talking to a 19.2 node. + optional bool to_is_learner = 7 [(gogoproto.nullable) = false]; } // RaftMessageRequest is the request used to send raft messages using our diff --git a/pkg/storage/replica_init.go b/pkg/storage/replica_init.go index c775a821e2ff..f8ce88719127 100644 --- a/pkg/storage/replica_init.go +++ b/pkg/storage/replica_init.go @@ -168,12 +168,8 @@ func (r *Replica) setReplicaIDRaftMuLockedMuLocked( if r.mu.replicaID != 0 { log.Fatalf(ctx, "cannot set replica ID from anything other than 0, currently %d", r.mu.replicaID) - } - if replicaID == 0 { - // If the incoming message does not have a new replica ID it is a - // preemptive snapshot. We'll update minReplicaID if the snapshot is - // accepted. - return nil + } else if replicaID == 0 { + log.Fatalf(ctx, "cannot set replica ID from anything to 0: %v", r) } if replicaID < r.mu.tombstoneMinReplicaID { return &roachpb.RaftGroupDeletedError{} diff --git a/pkg/storage/replica_raft.go b/pkg/storage/replica_raft.go index cf4c80e71603..a0b72af6f6c4 100644 --- a/pkg/storage/replica_raft.go +++ b/pkg/storage/replica_raft.go @@ -1052,6 +1052,7 @@ func (r *Replica) maybeCoalesceHeartbeat( Term: msg.Term, Commit: msg.Commit, Quiesce: quiesce, + ToIsLearner: toReplica.GetType() == roachpb.LEARNER, } if log.V(4) { log.Infof(ctx, "coalescing beat: %+v", beat) @@ -1578,7 +1579,16 @@ func (r *Replica) maybeAcquireSplitMergeLock( func (r *Replica) acquireSplitLock( ctx context.Context, split *roachpb.SplitTrigger, ) (func(), error) { - rightRng, _, err := r.store.getOrCreateReplica(ctx, split.RightDesc.RangeID, 0, nil) + // We pass a 0 replicaID because we want to lock the RHS even if we know + // it to be newer than the split so that we can properly clean up its + // state. We could imagine alternatively handling the RaftGroupDeleted + // error here and then not being guaranteed a Replica in the pre and post + // split apply hooks but that doesn't necessarily seem worth it. + const replicaID = 0 + rightReplDesc, _ := split.RightDesc.GetReplicaDescriptor(r.StoreID()) + rightRng, _, err := r.store.getOrCreateReplica(ctx, split.RightDesc.RangeID, + replicaID, nil, /* creatingReplica */ + rightReplDesc.GetType() == roachpb.LEARNER) if err != nil { return nil, err } @@ -1600,7 +1610,18 @@ func (r *Replica) acquireMergeLock( // right-hand replica in place, any snapshots for the right-hand range will // block on raftMu, waiting for the merge to complete, after which the replica // will realize it has been destroyed and reject the snapshot. - rightRepl, _, err := r.store.getOrCreateReplica(ctx, merge.RightDesc.RangeID, 0, nil) + // + // These guarantees would not be held if we were catching up from a preemptive + // snapshot and were not part of the range. That scenario, however, never + // arises because prior to 19.2 we would ensure that a preemptive snapshot had + // been applied before adding a store to the range which would fail if the + // range had merged another range and in 19.2 we detect if the raft messages + // we're processing are for a learner and our current state is due to a + // preemptive snapshot and remove the preemptive snapshot. + rightReplDesc, _ := merge.RightDesc.GetReplicaDescriptor(r.StoreID()) + rightRepl, _, err := r.store.getOrCreateReplica(ctx, merge.RightDesc.RangeID, + rightReplDesc.ReplicaID, nil, /* creatingReplica */ + rightReplDesc.GetType() == roachpb.LEARNER) if err != nil { return nil, err } diff --git a/pkg/storage/store.go b/pkg/storage/store.go index e36503ad2090..c66e22d3cba5 100644 --- a/pkg/storage/store.go +++ b/pkg/storage/store.go @@ -2583,7 +2583,7 @@ func (s *Store) RemoveReplica( // initialized the RemoveOptions will be consulted. func (s *Store) removeReplicaRaftMuLocked( ctx context.Context, rep *Replica, nextReplicaID roachpb.ReplicaID, opts RemoveOptions, -) (err error) { +) error { rep.raftMu.AssertHeld() if rep.IsInitialized() { return errors.Wrap(s.removeInitializedReplicaRaftMuLocked(ctx, rep, nextReplicaID, opts), @@ -3374,6 +3374,9 @@ func (s *Store) HandleSnapshot( }) } +// learnerType exists to avoid allocating on every coalesced beat to a learner. +var learnerType = roachpb.LEARNER + func (s *Store) uncoalesceBeats( ctx context.Context, beats []RaftHeartbeat, @@ -3411,6 +3414,9 @@ func (s *Store) uncoalesceBeats( Message: msg, Quiesce: beat.Quiesce, } + if beat.ToIsLearner { + beatReqs[i].ToReplica.Type = &learnerType + } if log.V(4) { log.Infof(ctx, "uncoalesced beat: %+v", beatReqs[i]) } @@ -3497,6 +3503,7 @@ func (s *Store) withReplicaForRequest( req.RangeID, req.ToReplica.ReplicaID, &req.FromReplica, + req.ToReplica.GetType() == roachpb.LEARNER, ) if err != nil { return roachpb.NewError(err) @@ -4051,6 +4058,7 @@ func (s *Store) getOrCreateReplica( rangeID roachpb.RangeID, replicaID roachpb.ReplicaID, creatingReplica *roachpb.ReplicaDescriptor, + isLearner bool, ) (_ *Replica, created bool, _ error) { // We need a retry loop as the replica we find in the map may be in the // process of being removed or may need to be removed. Retries in the loop @@ -4069,6 +4077,7 @@ func (s *Store) getOrCreateReplica( rangeID, replicaID, creatingReplica, + isLearner, ) if err == errRetry { continue @@ -4091,40 +4100,70 @@ func (s *Store) tryGetOrCreateReplica( rangeID roachpb.RangeID, replicaID roachpb.ReplicaID, creatingReplica *roachpb.ReplicaDescriptor, + isLearner bool, ) (_ *Replica, created bool, _ error) { - // NB: All of the below closures assume that both the raftMu and mu are held - // for the passed Replica. - // The common case: look up an existing (initialized) replica. if value, ok := s.mu.replicas.Load(int64(rangeID)); ok { repl := (*Replica)(value) repl.raftMu.Lock() // not unlocked on success repl.mu.Lock() - defer repl.mu.Unlock() - if err := s.tryGetOrCreateHandleFromReplicaTooOld(ctx, repl, creatingReplica); err != nil { + + // Drop messages from replicas we know to be too old. + if fromReplicaIsTooOld(repl, creatingReplica) { + repl.mu.Unlock() repl.raftMu.Unlock() - return nil, false, err + return nil, false, roachpb.NewReplicaTooOldError(creatingReplica.ReplicaID) } + + // The current replica is removed, go back around. if repl.mu.destroyStatus.Removed() { + repl.mu.Unlock() repl.raftMu.Unlock() return nil, false, errRetry } - if err := s.tryGetOrCreateHandleToReplicaTooOld(ctx, repl, replicaID); err != nil { + + toTooOld := toReplicaIsTooOld(repl, replicaID) + isPreemptiveSnapshot := repl.mu.replicaID == 0 && repl.isInitializedRLocked() + removePreemetiveSnapshot := isPreemptiveSnapshot && isLearner + // The current replica needs to be removed, remove it and go back around. + if toTooOld || removePreemetiveSnapshot { + + if shouldLog := log.V(1); shouldLog && toTooOld { + log.Infof(ctx, "found message for replica ID %d which is newer than %v", + replicaID, repl) + } else if shouldLog /* && removePreemptiveSnapshot */ { + log.Infof(ctx, "found message for replica ID %v as non-voter but "+ + "currently not part of the range, destroying preemptive snapshot", + replicaID) + } + + repl.mu.Unlock() + if err := s.removeReplicaRaftMuLocked(ctx, repl, replicaID, RemoveOptions{ + DestroyData: true, + }); err != nil { + log.Fatalf(ctx, "failed to remove replica: %v", err) + } repl.raftMu.Unlock() - return nil, false, err + return nil, false, errRetry } + defer repl.mu.Unlock() + // If this is intended for replicaID 0 then it's either a preemptive + // snapshot or a split/merge lock in which case we'll let it go through. + if replicaID == 0 { + return repl, false, nil + } var err error if repl.mu.replicaID == 0 { // This message is telling us about our replica ID. // This is a common case when dealing with preemptive snapshots. err = repl.setReplicaIDRaftMuLockedMuLocked(repl.AnnotateCtx(ctx), replicaID) - } else if replicaID != 0 && repl.mu.replicaID > replicaID { + } else if repl.mu.replicaID > replicaID { // The sender is behind and is sending to an old replica. // We could silently drop this message but this way we'll inform the // sender that they may no longer exist. err = roachpb.NewRangeNotFoundError(rangeID, s.StoreID()) - } else if replicaID != 0 && repl.mu.replicaID != replicaID { + } else if repl.mu.replicaID != replicaID { // This case should have been caught by handleToReplicaTooOld. log.Fatalf(ctx, "intended replica id %d unexpectedly does not match the current replica %v", replicaID, repl) @@ -4226,43 +4265,26 @@ func (s *Store) tryGetOrCreateReplica( return repl, true, nil } -// Drop messages that come from a node that we believe was once a member of -// the group but has been removed. Assumes that repl.mu and repl.raftMu are both -// held. -func (s *Store) tryGetOrCreateHandleFromReplicaTooOld( - ctx context.Context, repl *Replica, creatingReplica *roachpb.ReplicaDescriptor, -) error { - if creatingReplica == nil { - return nil - } - desc := repl.mu.state.Desc - _, found := desc.GetReplicaDescriptorByID(creatingReplica.ReplicaID) - // It's not a current member of the group. Is it from the past? - if !found && creatingReplica.ReplicaID < desc.NextReplicaID { - return roachpb.NewReplicaTooOldError(creatingReplica.ReplicaID) +// isFromReplicaTooOld returns an true if the creatingReplica is deemed to be +// a member of the range which has been removed. +// Assumes toReplica.mu is held. +func fromReplicaIsTooOld(toReplica *Replica, fromReplica *roachpb.ReplicaDescriptor) bool { + toReplica.mu.AssertHeld() + if fromReplica == nil { + return false } - return nil + desc := toReplica.mu.state.Desc + _, found := desc.GetReplicaDescriptorByID(fromReplica.ReplicaID) + return !found && fromReplica.ReplicaID < desc.NextReplicaID } -// Detect if the replicaID is newer than repl indicating that repl needs to be -// removed. Assumes that repl.mu and repl.raftMu are both held. -func (s *Store) tryGetOrCreateHandleToReplicaTooOld( - ctx context.Context, repl *Replica, replicaID roachpb.ReplicaID, -) error { - if replicaID == 0 || repl.mu.replicaID == 0 || repl.mu.replicaID >= replicaID { - return nil - } - if log.V(1) { - log.Infof(ctx, "found message for replica ID %d which is newer than %v", replicaID, repl) - } - repl.mu.Unlock() - defer repl.mu.Lock() - if err := s.removeReplicaRaftMuLocked(ctx, repl, replicaID, RemoveOptions{ - DestroyData: true, - }); err != nil { - log.Fatal(ctx, err) - } - return errRetry +// toReplicaIsTooOld returns true if replicaID is newer than toReplica +// indicating that the Replica needs to be removed. +// Assumes toReplica.mu is held. +func toReplicaIsTooOld(toReplica *Replica, replicaID roachpb.ReplicaID) bool { + toReplica.mu.AssertHeld() + return replicaID != 0 && toReplica.mu.replicaID != 0 && + toReplica.mu.replicaID < replicaID } func (s *Store) updateCapacityGauges() error { diff --git a/pkg/storage/store_snapshot.go b/pkg/storage/store_snapshot.go index 2c789b2d1cbb..432f5ad44a91 100644 --- a/pkg/storage/store_snapshot.go +++ b/pkg/storage/store_snapshot.go @@ -744,11 +744,15 @@ func (s *Store) shouldAcceptSnapshotData( } pErr := s.withReplicaForRequest(ctx, &snapHeader.RaftMessageRequest, func(ctx context.Context, r *Replica) *roachpb.Error { + // If the current replica is not initialized then we should accept this + // snapshot if it doesn't overlap existing ranges. if !r.IsInitialized() { s.mu.Lock() defer s.mu.Unlock() return roachpb.NewError(s.checkSnapshotOverlapLocked(ctx, snapHeader)) } + // If the current range is initialized then we need to accept this + // snapshot. return nil }) return pErr.GoError() diff --git a/pkg/storage/store_snapshot_test.go b/pkg/storage/store_snapshot_test.go index 12c10f2e7316..adec003cf74f 100644 --- a/pkg/storage/store_snapshot_test.go +++ b/pkg/storage/store_snapshot_test.go @@ -114,7 +114,7 @@ func TestSnapshotPreemptiveOnUninitializedReplica(t *testing.T) { store, _ := createTestStore(t, testStoreOpts{}, stopper) // Create an uninitialized replica. - repl, created, err := store.getOrCreateReplica(ctx, 77, 1, nil) + repl, created, err := store.getOrCreateReplica(ctx, 77, 1, nil, true) if err != nil { t.Fatal(err) } diff --git a/pkg/storage/stores_test.go b/pkg/storage/stores_test.go index 4900dfccdfc4..51840b2650c5 100644 --- a/pkg/storage/stores_test.go +++ b/pkg/storage/stores_test.go @@ -118,9 +118,10 @@ func TestStoresGetReplicaForRangeID(t *testing.T) { ls := newStores(log.AmbientContext{}, clock) numStores := 10 - for i := 0; i < numStores; i++ { + for i := 1; i <= numStores; i++ { storeID := roachpb.StoreID(i) rangeID := roachpb.RangeID(i) + replicaID := roachpb.ReplicaID(1) memEngine := engine.NewInMem(roachpb.Attributes{}, 1<<20) stopper.AddCloser(memEngine) @@ -135,10 +136,16 @@ func TestStoresGetReplicaForRangeID(t *testing.T) { ls.AddStore(store) desc := &roachpb.RangeDescriptor{ - RangeID: rangeID, - StartKey: roachpb.RKey("a"), - EndKey: roachpb.RKey("b"), - InternalReplicas: []roachpb.ReplicaDescriptor{{StoreID: storeID}}, + RangeID: rangeID, + StartKey: roachpb.RKey("a"), + EndKey: roachpb.RKey("b"), + InternalReplicas: []roachpb.ReplicaDescriptor{ + { + StoreID: storeID, + ReplicaID: replicaID, + NodeID: 1, + }, + }, } replica, err := NewReplica(desc, store, 0)