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_application_state_machine.go b/pkg/storage/replica_application_state_machine.go index a6b83c3c846b..605b15fa99f9 100644 --- a/pkg/storage/replica_application_state_machine.go +++ b/pkg/storage/replica_application_state_machine.go @@ -439,7 +439,25 @@ func (b *replicaAppBatch) Stage(cmdI apply.Command) (apply.CheckedCommand, error log.Event(ctx, "applying command") } - // Acquire the split or merge lock, if necessary. If a split or merge + // There's a nasty edge case here which only exists in 19.2 (for subtle + // reasons). + // + // Imagine we're catching up from a pre-emptive snapshot and we come across + // a merge, we're not gaurenteed that the RHS is going to be present. One + // option might be to destroy the current replica. Unfortunately we might + // also gotten raft messages and voted so we'll know our replica ID but our + // current view of the range descriptor will not include the current store. + // + // * One proposal is to just refuse to apply the current command and just spin + // handling raft ready objects but not actually applying any commands but + // detecting the illegal merge and truncating the CommittedEntries slice + // to before the merge prior to calling Advance. + // * The other is to permit destroying an initialized replica with + // nextReplicaID == Replica.mu.replicaID if the store is not in + // Replica.mu.state.Desc. We'd need to make sure to preserve the hard state + // in this case. + + // acquire the split or merge lock, if necessary. If a split or merge // command was rejected with a below-Raft forced error then its replicated // result was just cleared and this will be a no-op. if splitMergeUnlock, err := b.r.maybeAcquireSplitMergeLock(ctx, cmd.raftCmd); err != nil { diff --git a/pkg/storage/replica_raft.go b/pkg/storage/replica_raft.go index aa68401ea88a..64b32169203a 100644 --- a/pkg/storage/replica_raft.go +++ b/pkg/storage/replica_raft.go @@ -1048,6 +1048,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) @@ -1572,7 +1573,7 @@ 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) + rightRng, _, err := r.store.getOrCreateReplica(ctx, split.RightDesc.RangeID, 0, nil, true) if err != nil { return nil, err } @@ -1594,7 +1595,13 @@ 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) + // + // There's one edge case to this requirement: the current Replica may be + // catching up from a pre-emptive snapshot. This case only arises in v19.2 + // while performing the upgrade. If we detect that we're not a part of this + // range then it's not safe to apply this merge. In that case we need to + // remove the LHS replica synchronously. + rightRepl, _, err := r.store.getOrCreateReplica(ctx, merge.RightDesc.RangeID, 0, nil, true) if err != nil { return nil, err } diff --git a/pkg/storage/store.go b/pkg/storage/store.go index 068270f9bcc6..b415c91d7a6a 100644 --- a/pkg/storage/store.go +++ b/pkg/storage/store.go @@ -3356,6 +3356,10 @@ func (s *Store) HandleSnapshot( }) } +// learnerReplicaType exists to avoid allocating when marking a replica as a +// learner in uncoalesceBeats. +var learnerReplicaType = roachpb.LEARNER + func (s *Store) uncoalesceBeats( ctx context.Context, beats []RaftHeartbeat, @@ -3393,6 +3397,9 @@ func (s *Store) uncoalesceBeats( Message: msg, Quiesce: beat.Quiesce, } + if beat.ToIsLearner { + beatReqs[i].ToReplica.Type = &learnerReplicaType + } if log.V(4) { log.Infof(ctx, "uncoalesced beat: %+v", beatReqs[i]) } @@ -3479,6 +3486,7 @@ func (s *Store) withReplicaForRequest( req.RangeID, req.ToReplica.ReplicaID, &req.FromReplica, + req.ToReplica.GetType() == roachpb.VOTER_FULL, ) if err != nil { return roachpb.NewError(err) @@ -4063,6 +4071,7 @@ func (s *Store) getOrCreateReplica( rangeID roachpb.RangeID, replicaID roachpb.ReplicaID, creatingReplica *roachpb.ReplicaDescriptor, + isVoter bool, ) (_ *Replica, created bool, _ error) { r := retry.Start(retry.Options{ InitialBackoff: time.Microsecond, @@ -4075,6 +4084,7 @@ func (s *Store) getOrCreateReplica( rangeID, replicaID, creatingReplica, + isVoter, ) if err == errRetry { continue @@ -4097,8 +4107,27 @@ func (s *Store) tryGetOrCreateReplica( rangeID roachpb.RangeID, replicaID roachpb.ReplicaID, creatingReplica *roachpb.ReplicaDescriptor, + isVoter bool, ) (_ *Replica, created bool, err error) { var ( + removeReplica = func(repl *Replica) error { + repl.mu.destroyStatus.Set(err, destroyReasonRemovalPending) + isInitialized := repl.isInitializedRLocked() + repl.mu.Unlock() + defer repl.mu.Lock() + if !isInitialized { + if err := s.removeUninitializedReplicaRaftMuLocked(ctx, repl, replicaID); err != nil { + log.Fatalf(ctx, "failed to remove uninitialized replica: %v", err) + } + } else { + if err := s.removeReplicaImpl(ctx, repl, replicaID, RemoveOptions{ + DestroyData: true, + }); err != nil { + log.Fatal(ctx, err) + } + } + return errRetry + } handleFromReplicaTooOld = func(repl *Replica) error { if creatingReplica == nil { return nil @@ -4120,22 +4149,16 @@ func (s *Store) tryGetOrCreateReplica( if log.V(1) { log.Infof(ctx, "found message for newer replica ID: %v %v %v %v %v", repl.mu.replicaID, replicaID, repl.mu.minReplicaID, repl.mu.state.Desc, &repl.mu.destroyStatus) } - repl.mu.destroyStatus.Set(err, destroyReasonRemovalPending) - isInitialized := repl.isInitializedRLocked() - repl.mu.Unlock() - defer repl.mu.Lock() - if !isInitialized { - if err := s.removeUninitializedReplicaRaftMuLocked(ctx, repl, replicaID); err != nil { - log.Fatalf(ctx, "failed to remove uninitialized replica: %v", err) - } - } else { - if err := s.removeReplicaImpl(ctx, repl, replicaID, RemoveOptions{ - DestroyData: true, - }); err != nil { - log.Fatal(ctx, err) - } + return removeReplica(repl) + } + handleNonVoterWithPreemptiveSnapshot = func(repl *Replica) error { + if repl.mu.replicaID != 0 || replicaID == 0 || !repl.isInitializedRLocked() || isVoter { + return nil } - return errRetry + if log.V(1) { + log.Infof(ctx, "found message for replica ID %v as non-voter but currently not part of the range, destroying preemptive snapshot", replicaID) + } + return removeReplica(repl) } ) // The common case: look up an existing (initialized) replica. @@ -4156,11 +4179,16 @@ func (s *Store) tryGetOrCreateReplica( repl.raftMu.Unlock() return nil, false, err } + if err := handleNonVoterWithPreemptiveSnapshot(repl); err != nil { + repl.raftMu.Unlock() + return nil, false, err + } var err error - if repl.mu.replicaID == 0 { + if repl.mu.replicaID == 0 && replicaID != 0 { // This message is telling us about our replica ID. - // This is a common case when dealing with preemptive snapshots. + // This is a common case when dealing with preemptive snapshots if we're + // initialized. err = repl.setReplicaIDRaftMuLockedMuLocked(repl.AnnotateCtx(ctx), replicaID) } else if replicaID != 0 && repl.mu.replicaID > replicaID { // TODO(ajwerner): probably just silently drop this message. diff --git a/pkg/storage/store_snapshot.go b/pkg/storage/store_snapshot.go index 2674ed25f2e9..9c138f8846ec 100644 --- a/pkg/storage/store_snapshot.go +++ b/pkg/storage/store_snapshot.go @@ -744,11 +744,19 @@ 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 + // this snapshot. There's a hidden nasty case here during 19.2 where + // our currently initialized range is due to a preemptive snapshot and + // we've now assigned that range a replica ID. Fundamentally at this + // point we want to clear out the pre-emptive snapshot because applying + // learner snapshot over top is likely going to be problematic. return nil }) return pErr.GoError() diff --git a/pkg/storage/store_snapshot_test.go b/pkg/storage/store_snapshot_test.go index 12c10f2e7316..74f3aaef5cde 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) } @@ -141,3 +141,15 @@ func TestSnapshotPreemptiveOnUninitializedReplica(t *testing.T) { t.Fatal(err) } } + +// TestSnapshotPreemptiveRemovedAfterMessageToNonVoter tests that replicas which +// encounter preemptive snapshots remove all of the data due to that preemptive +// snapshot. +// +// This behavior is critical to provide safety when upgrading from preemptive +// snapshots. Before learner replicas we would not add a store to a range +// until we had successfully sent a preemptive snapshot. Furthermore we'd +// only add that store assuming that the +func TestPreemptiveSnapshotRemovedAfterMessageTo(t *testing.T) { + +}