diff --git a/raft/raftpb/raft.pb.go b/raft/raftpb/raft.pb.go index 1284287335d0..5795b023e10a 100644 --- a/raft/raftpb/raft.pb.go +++ b/raft/raftpb/raft.pb.go @@ -73,25 +73,29 @@ func (EntryType) EnumDescriptor() ([]byte, []int) { type MessageType int32 const ( - MsgHup MessageType = 0 - MsgBeat MessageType = 1 - MsgProp MessageType = 2 - MsgApp MessageType = 3 - MsgAppResp MessageType = 4 - MsgVote MessageType = 5 - MsgVoteResp MessageType = 6 - MsgSnap MessageType = 7 - MsgHeartbeat MessageType = 8 - MsgHeartbeatResp MessageType = 9 - MsgUnreachable MessageType = 10 - MsgSnapStatus MessageType = 11 - MsgCheckQuorum MessageType = 12 - MsgTransferLeader MessageType = 13 - MsgTimeoutNow MessageType = 14 - MsgReadIndex MessageType = 15 - MsgReadIndexResp MessageType = 16 - MsgPreVote MessageType = 17 - MsgPreVoteResp MessageType = 18 + MsgHup MessageType = 0 + MsgBeat MessageType = 1 + MsgProp MessageType = 2 + MsgApp MessageType = 3 + MsgAppResp MessageType = 4 + MsgVote MessageType = 5 + MsgVoteResp MessageType = 6 + MsgSnap MessageType = 7 + MsgHeartbeat MessageType = 8 + MsgHeartbeatResp MessageType = 9 + MsgUnreachable MessageType = 10 + MsgSnapStatus MessageType = 11 + MsgCheckQuorum MessageType = 12 + MsgTransferLeader MessageType = 13 + MsgTimeoutNow MessageType = 14 + MsgReadIndex MessageType = 15 + MsgReadIndexResp MessageType = 16 + MsgPreVote MessageType = 17 + MsgPreVoteResp MessageType = 18 + MsgStorageAppend MessageType = 19 + MsgStorageAppendResp MessageType = 20 + MsgStorageApply MessageType = 21 + MsgStorageApplyResp MessageType = 22 ) var MessageType_name = map[int32]string{ @@ -114,28 +118,36 @@ var MessageType_name = map[int32]string{ 16: "MsgReadIndexResp", 17: "MsgPreVote", 18: "MsgPreVoteResp", + 19: "MsgStorageAppend", + 20: "MsgStorageAppendResp", + 21: "MsgStorageApply", + 22: "MsgStorageApplyResp", } var MessageType_value = map[string]int32{ - "MsgHup": 0, - "MsgBeat": 1, - "MsgProp": 2, - "MsgApp": 3, - "MsgAppResp": 4, - "MsgVote": 5, - "MsgVoteResp": 6, - "MsgSnap": 7, - "MsgHeartbeat": 8, - "MsgHeartbeatResp": 9, - "MsgUnreachable": 10, - "MsgSnapStatus": 11, - "MsgCheckQuorum": 12, - "MsgTransferLeader": 13, - "MsgTimeoutNow": 14, - "MsgReadIndex": 15, - "MsgReadIndexResp": 16, - "MsgPreVote": 17, - "MsgPreVoteResp": 18, + "MsgHup": 0, + "MsgBeat": 1, + "MsgProp": 2, + "MsgApp": 3, + "MsgAppResp": 4, + "MsgVote": 5, + "MsgVoteResp": 6, + "MsgSnap": 7, + "MsgHeartbeat": 8, + "MsgHeartbeatResp": 9, + "MsgUnreachable": 10, + "MsgSnapStatus": 11, + "MsgCheckQuorum": 12, + "MsgTransferLeader": 13, + "MsgTimeoutNow": 14, + "MsgReadIndex": 15, + "MsgReadIndexResp": 16, + "MsgPreVote": 17, + "MsgPreVoteResp": 18, + "MsgStorageAppend": 19, + "MsgStorageAppendResp": 20, + "MsgStorageApply": 21, + "MsgStorageApplyResp": 22, } func (x MessageType) Enum() *MessageType { @@ -387,14 +399,20 @@ type Message struct { From uint64 `protobuf:"varint,3,opt,name=from" json:"from"` Term uint64 `protobuf:"varint,4,opt,name=term" json:"term"` // logTerm is generally used for appending Raft logs to followers. For example, - // (type=MsgApp,index=100,logTerm=5) means leader appends entries starting at - // index=101, and the term of entry at index 100 is 5. + // (type=MsgApp,index=100,logTerm=5) means the leader appends entries starting + // at index=101, and the term of the entry at index 100 is 5. // (type=MsgAppResp,reject=true,index=100,logTerm=5) means follower rejects some // entries from its leader as it already has an entry with term 5 at index 100. + // (type=MsgStorageAppendResp,index=100,logTerm=5) means the local node wrote + // entries up to index=100 in stable storage, and the term of the entry at index + // 100 was 5. LogTerm uint64 `protobuf:"varint,5,opt,name=logTerm" json:"logTerm"` Index uint64 `protobuf:"varint,6,opt,name=index" json:"index"` Entries []Entry `protobuf:"bytes,7,rep,name=entries" json:"entries"` Commit uint64 `protobuf:"varint,8,opt,name=commit" json:"commit"` + // hardState can be non-nil for MsgStorageAppend messages and is nil for all + // other message types. + HardState *HardState `protobuf:"bytes,13,opt,name=hardState" json:"hardState,omitempty"` // snapshot is non-nil and non-empty for MsgSnap messages and nil for all other // message types. However, peer nodes running older binary versions may send a // non-nil, empty value for the snapshot field of non-MsgSnap messages. Code @@ -403,6 +421,10 @@ type Message struct { Reject bool `protobuf:"varint,10,opt,name=reject" json:"reject"` RejectHint uint64 `protobuf:"varint,11,opt,name=rejectHint" json:"rejectHint"` Context []byte `protobuf:"bytes,12,opt,name=context" json:"context,omitempty"` + // responses are populated by a raft node to instruct storage threads on how + // to respond and who to respond to when the work associated with a message + // is complete. Populated for MsgStorageAppend and MsgStorageApply messages. + Responses []Message `protobuf:"bytes,14,rep,name=responses" json:"responses"` } func (m *Message) Reset() { *m = Message{} } @@ -700,75 +722,80 @@ func init() { func init() { proto.RegisterFile("raft.proto", fileDescriptor_b042552c306ae59b) } var fileDescriptor_b042552c306ae59b = []byte{ - // 1081 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xcf, 0x6b, 0xe3, 0x46, - 0x14, 0xd6, 0xc8, 0x8a, 0x65, 0x3f, 0x3b, 0xce, 0x64, 0x36, 0x5d, 0x84, 0x59, 0xb4, 0xae, 0x77, - 0xcb, 0x9a, 0x94, 0x4d, 0x16, 0x77, 0x29, 0x65, 0x6f, 0xf9, 0xb1, 0x90, 0x94, 0x38, 0xdd, 0x3a, - 0xd9, 0x1c, 0x16, 0x4a, 0x98, 0x58, 0x63, 0x45, 0xad, 0xad, 0x11, 0xd2, 0x38, 0x4d, 0x6e, 0xa5, - 0x97, 0x1e, 0x7a, 0x29, 0x3d, 0x95, 0x42, 0xaf, 0xbd, 0x16, 0x0a, 0xfd, 0x1f, 0x72, 0x0c, 0xf4, - 0xd2, 0xd3, 0xd2, 0x4d, 0xfe, 0x91, 0x32, 0xa3, 0x91, 0x25, 0x3b, 0x61, 0x0f, 0xbd, 0xcd, 0x7c, - 0xdf, 0x37, 0xef, 0x7d, 0xef, 0xbd, 0xd1, 0x08, 0x20, 0xa6, 0x43, 0xb1, 0x16, 0xc5, 0x5c, 0x70, - 0x52, 0x96, 0xeb, 0xe8, 0xa4, 0xb9, 0xe2, 0x73, 0x9f, 0x2b, 0x68, 0x5d, 0xae, 0x52, 0xb6, 0xd9, - 0x62, 0x62, 0xe0, 0xad, 0xd3, 0x28, 0x58, 0x3f, 0x63, 0x71, 0x12, 0xf0, 0x30, 0x3a, 0xc9, 0x56, - 0xa9, 0xa2, 0xfd, 0x03, 0x82, 0x85, 0x97, 0xa1, 0x88, 0x2f, 0x88, 0x03, 0xd6, 0x21, 0x8b, 0xc7, - 0x8e, 0xd9, 0x42, 0x1d, 0x6b, 0xd3, 0xba, 0x7c, 0xfb, 0xd0, 0xe8, 0x2b, 0x84, 0x34, 0x61, 0x61, - 0x37, 0xf4, 0xd8, 0xb9, 0x53, 0x2a, 0x50, 0x29, 0x44, 0x3e, 0x06, 0xeb, 0xf0, 0x22, 0x62, 0x0e, - 0x6a, 0xa1, 0x4e, 0xa3, 0xbb, 0xbc, 0x96, 0xda, 0x59, 0x53, 0x21, 0x25, 0x31, 0x0d, 0x74, 0x11, - 0x31, 0x42, 0xc0, 0xda, 0xa6, 0x82, 0x3a, 0x56, 0x0b, 0x75, 0xea, 0x7d, 0xb5, 0x7e, 0x61, 0x7f, - 0xff, 0x97, 0x53, 0xfa, 0x64, 0xed, 0x59, 0xfb, 0x3b, 0x04, 0xf8, 0x20, 0xa4, 0x51, 0x72, 0xca, - 0x45, 0x8f, 0x09, 0xea, 0x51, 0x41, 0xc9, 0xa7, 0x00, 0x03, 0x1e, 0x0e, 0x8f, 0x13, 0x41, 0x45, - 0x9a, 0xa4, 0x96, 0x27, 0x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x63, 0x80, 0x74, 0xb5, - 0x13, 0x84, 0xc2, 0xa9, 0x15, 0x72, 0x16, 0x70, 0xe2, 0x80, 0x3d, 0xe0, 0xa1, 0x60, 0xe7, 0xc2, - 0xa9, 0xab, 0xc1, 0x66, 0xdb, 0xf6, 0x57, 0x50, 0xdd, 0xa1, 0xb1, 0x97, 0x5e, 0x9f, 0xac, 0x83, - 0xe8, 0x56, 0x07, 0x1d, 0xb0, 0xce, 0xb8, 0x60, 0xb3, 0x5f, 0x89, 0x44, 0x0a, 0x05, 0x97, 0x6e, - 0x17, 0xdc, 0xfe, 0x13, 0x41, 0x75, 0x7a, 0x5f, 0xc9, 0x7d, 0x28, 0xcb, 0x33, 0x71, 0xe2, 0xa0, - 0x56, 0xa9, 0x63, 0xf5, 0xf5, 0x8e, 0x34, 0xa1, 0x32, 0x62, 0x34, 0x0e, 0x25, 0x63, 0x2a, 0x66, - 0xba, 0x27, 0x4f, 0x60, 0x29, 0x55, 0x1d, 0xf3, 0x89, 0xf0, 0x79, 0x10, 0xfa, 0x4e, 0x49, 0x49, - 0x1a, 0x29, 0xfc, 0x85, 0x46, 0xc9, 0x23, 0x58, 0xcc, 0x0e, 0x1d, 0x87, 0xb2, 0x52, 0x4b, 0xc9, - 0xea, 0x19, 0xb8, 0xcf, 0xce, 0x05, 0x79, 0x04, 0x40, 0x27, 0x82, 0x1f, 0x8f, 0x18, 0x3d, 0x63, - 0xea, 0x32, 0x64, 0x0d, 0xad, 0x4a, 0x7c, 0x4f, 0xc2, 0xed, 0xdf, 0x11, 0x80, 0x34, 0xbd, 0x75, - 0x4a, 0x43, 0x9f, 0x91, 0x67, 0xfa, 0xda, 0x9a, 0xea, 0xda, 0xde, 0x2f, 0x7e, 0x86, 0xa9, 0xe2, - 0xd6, 0xcd, 0x7d, 0x02, 0x76, 0xc8, 0x3d, 0x76, 0x1c, 0x78, 0xba, 0x29, 0x0d, 0x49, 0x5e, 0xbf, - 0x7d, 0x58, 0xde, 0xe7, 0x1e,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, 0x7d, 0x96, 0x44, 0xd8, - 0xd2, 0xc2, 0x23, 0x2e, 0x18, 0x5e, 0x90, 0x6e, 0xf5, 0x46, 0xb1, 0x65, 0xcd, 0xca, 0x67, 0x02, - 0xdb, 0x04, 0x43, 0x5d, 0x26, 0x63, 0x34, 0x16, 0x27, 0x32, 0x4b, 0x85, 0xac, 0x00, 0x2e, 0x22, - 0xea, 0x50, 0x95, 0x10, 0x68, 0xf4, 0x12, 0xff, 0x75, 0x18, 0x33, 0x3a, 0x38, 0xa5, 0x27, 0x23, - 0x86, 0x81, 0x2c, 0xc3, 0xa2, 0x0e, 0x24, 0xbf, 0xca, 0x49, 0x82, 0x6b, 0x5a, 0xb6, 0x75, 0xca, - 0x06, 0xdf, 0x7c, 0x39, 0xe1, 0xf1, 0x64, 0x8c, 0xeb, 0xe4, 0x03, 0x58, 0xee, 0x25, 0xbe, 0x9a, - 0xdd, 0x90, 0xc5, 0x7b, 0x8c, 0x7a, 0x2c, 0xc6, 0x8b, 0xfa, 0xf4, 0x61, 0x30, 0x66, 0x7c, 0x22, - 0xf6, 0xf9, 0xb7, 0xb8, 0xa1, 0xcd, 0xf4, 0x19, 0xf5, 0xd4, 0xcf, 0x11, 0x2f, 0x69, 0x33, 0x53, - 0x44, 0x99, 0xc1, 0xba, 0xde, 0x57, 0x31, 0x53, 0x25, 0x2e, 0xeb, 0xac, 0x7a, 0xaf, 0x34, 0x64, - 0xf5, 0x47, 0x04, 0x2b, 0x77, 0xdd, 0x1c, 0xf2, 0x00, 0x9c, 0xbb, 0xf0, 0x8d, 0x89, 0xe0, 0xd8, - 0x20, 0x1f, 0xc1, 0x87, 0x77, 0xb1, 0x9f, 0xf3, 0x20, 0x14, 0xbb, 0xe3, 0x68, 0x14, 0x0c, 0x02, - 0x39, 0x8a, 0xf7, 0xc9, 0x5e, 0x9e, 0x6b, 0x99, 0x99, 0xcd, 0xf8, 0xf9, 0xea, 0x05, 0x34, 0x66, - 0x3f, 0x1c, 0xd9, 0x95, 0x1c, 0xd9, 0xf0, 0x3c, 0xf9, 0x89, 0x60, 0x83, 0x38, 0x45, 0xd7, 0x7d, - 0x36, 0xe6, 0x67, 0x4c, 0x31, 0x68, 0x96, 0x79, 0x1d, 0x79, 0x54, 0xa4, 0x8c, 0x39, 0x5b, 0xd1, - 0x86, 0xe7, 0xed, 0xa5, 0x0f, 0x95, 0x62, 0x4b, 0x9b, 0x8f, 0x2f, 0xdf, 0xb9, 0xc6, 0xd5, 0x3b, - 0xd7, 0xb8, 0xbc, 0x76, 0xd1, 0xd5, 0xb5, 0x8b, 0xfe, 0xbd, 0x76, 0xd1, 0x4f, 0x37, 0xae, 0xf1, - 0xcb, 0x8d, 0x6b, 0x5c, 0xdd, 0xb8, 0xc6, 0x3f, 0x37, 0xae, 0xf1, 0x5f, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x08, 0xbd, 0x8b, 0xb2, 0x14, 0x09, 0x00, 0x00, + // 1153 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xcd, 0x6e, 0xdb, 0x46, + 0x10, 0x16, 0x29, 0x5a, 0x3f, 0x23, 0x59, 0x5e, 0xaf, 0x95, 0x94, 0x10, 0x0c, 0x46, 0x55, 0x52, + 0x44, 0x70, 0x11, 0x3b, 0x50, 0xd2, 0xa2, 0xc8, 0xcd, 0x3f, 0x01, 0xec, 0xc2, 0x72, 0x53, 0xd9, + 0xf1, 0x21, 0x40, 0x61, 0xac, 0xc5, 0x35, 0xcd, 0x56, 0xe2, 0x12, 0xcb, 0x95, 0x6b, 0xdf, 0x8a, + 0x5e, 0x7a, 0xe8, 0xa1, 0x45, 0x4f, 0x45, 0x1f, 0xa0, 0xd7, 0xa2, 0x05, 0xfa, 0x0e, 0x3e, 0xfa, + 0xd8, 0x53, 0xd0, 0xd8, 0x2f, 0x52, 0xec, 0x72, 0xf9, 0x23, 0xd9, 0xc8, 0xa1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c, 0x2e, 0xd0, 0x3d, 0xfc, + 0x01, 0x2c, 0xcd, 0x80, 0x8a, 0x7d, 0x7f, 0xe5, 0x47, 0x03, 0x9a, 0x77, 0xdd, 0x4b, 0xbc, 0x0c, + 0xf6, 0x5d, 0xf8, 0xfa, 0x44, 0x30, 0x54, 0xc0, 0x1f, 0xc1, 0x87, 0x77, 0x59, 0x3f, 0x67, 0x7e, + 0x20, 0x76, 0xc6, 0xe1, 0xc8, 0x1f, 0xfa, 0x72, 0xd0, 0xef, 0xa3, 0xbd, 0x3c, 0xd7, 0x34, 0x33, + 0xb9, 0x41, 0xcf, 0x57, 0x2e, 0xa0, 0x31, 0xbd, 0x96, 0xb2, 0xe7, 0x19, 0xb2, 0xee, 0xba, 0x72, + 0x01, 0x51, 0x41, 0x96, 0x9f, 0xc1, 0x03, 0x3a, 0x66, 0x67, 0x54, 0x59, 0x8c, 0x69, 0xcb, 0xeb, + 0xd0, 0x25, 0x22, 0xb6, 0x98, 0xd3, 0x15, 0xad, 0xbb, 0xee, 0x6e, 0xfc, 0x0c, 0x2a, 0x6b, 0x71, + 0xe3, 0xd1, 0xe5, 0x3b, 0xa7, 0x70, 0xf5, 0xce, 0x29, 0x5c, 0x5e, 0x3b, 0xc6, 0xd5, 0xb5, 0x63, + 0xfc, 0x7b, 0xed, 0x18, 0x3f, 0xdf, 0x38, 0x85, 0x5f, 0x6f, 0x9c, 0xc2, 0xd5, 0x8d, 0x53, 0xf8, + 0xe7, 0xc6, 0x29, 0xfc, 0x17, 0x00, 0x00, 0xff, 0xff, 0x83, 0x03, 0x52, 0x0e, 0xe4, 0x09, 0x00, + 0x00, } func (m *Entry) Marshal() (dAtA []byte, err error) { @@ -909,6 +936,32 @@ func (m *Message) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Responses) > 0 { + for iNdEx := len(m.Responses) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Responses[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRaft(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x72 + } + } + if m.HardState != nil { + { + size, err := m.HardState.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRaft(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x6a + } if m.Context != nil { i -= len(m.Context) copy(dAtA[i:], m.Context) @@ -1267,6 +1320,16 @@ func (m *Message) Size() (n int) { l = len(m.Context) n += 1 + l + sovRaft(uint64(l)) } + if m.HardState != nil { + l = m.HardState.Size() + n += 1 + l + sovRaft(uint64(l)) + } + if len(m.Responses) > 0 { + for _, e := range m.Responses { + l = e.Size() + n += 1 + l + sovRaft(uint64(l)) + } + } return n } @@ -2049,6 +2112,76 @@ func (m *Message) Unmarshal(dAtA []byte) error { m.Context = []byte{} } iNdEx = postIndex + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HardState", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRaft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRaft + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRaft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.HardState == nil { + m.HardState = &HardState{} + } + if err := m.HardState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 14: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Responses", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRaft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRaft + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRaft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Responses = append(m.Responses, Message{}) + if err := m.Responses[len(m.Responses)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipRaft(dAtA[iNdEx:]) diff --git a/raft/raftpb/raft.proto b/raft/raftpb/raft.proto index e0f6e7f1359f..59ecd097abf7 100644 --- a/raft/raftpb/raft.proto +++ b/raft/raftpb/raft.proto @@ -44,25 +44,29 @@ message Snapshot { // For description of different message types, see: // https://pkg.go.dev/go.etcd.io/etcd/raft/v3#hdr-MessageType enum MessageType { - MsgHup = 0; - MsgBeat = 1; - MsgProp = 2; - MsgApp = 3; - MsgAppResp = 4; - MsgVote = 5; - MsgVoteResp = 6; - MsgSnap = 7; - MsgHeartbeat = 8; - MsgHeartbeatResp = 9; - MsgUnreachable = 10; - MsgSnapStatus = 11; - MsgCheckQuorum = 12; - MsgTransferLeader = 13; - MsgTimeoutNow = 14; - MsgReadIndex = 15; - MsgReadIndexResp = 16; - MsgPreVote = 17; - MsgPreVoteResp = 18; + MsgHup = 0; + MsgBeat = 1; + MsgProp = 2; + MsgApp = 3; + MsgAppResp = 4; + MsgVote = 5; + MsgVoteResp = 6; + MsgSnap = 7; + MsgHeartbeat = 8; + MsgHeartbeatResp = 9; + MsgUnreachable = 10; + MsgSnapStatus = 11; + MsgCheckQuorum = 12; + MsgTransferLeader = 13; + MsgTimeoutNow = 14; + MsgReadIndex = 15; + MsgReadIndexResp = 16; + MsgPreVote = 17; + MsgPreVoteResp = 18; + MsgStorageAppend = 19; + MsgStorageAppendResp = 20; + MsgStorageApply = 21; + MsgStorageApplyResp = 22; } message Message { @@ -71,14 +75,20 @@ message Message { optional uint64 from = 3 [(gogoproto.nullable) = false]; optional uint64 term = 4 [(gogoproto.nullable) = false]; // logTerm is generally used for appending Raft logs to followers. For example, - // (type=MsgApp,index=100,logTerm=5) means leader appends entries starting at - // index=101, and the term of entry at index 100 is 5. + // (type=MsgApp,index=100,logTerm=5) means the leader appends entries starting + // at index=101, and the term of the entry at index 100 is 5. // (type=MsgAppResp,reject=true,index=100,logTerm=5) means follower rejects some // entries from its leader as it already has an entry with term 5 at index 100. + // (type=MsgStorageAppendResp,index=100,logTerm=5) means the local node wrote + // entries up to index=100 in stable storage, and the term of the entry at index + // 100 was 5. optional uint64 logTerm = 5 [(gogoproto.nullable) = false]; optional uint64 index = 6 [(gogoproto.nullable) = false]; repeated Entry entries = 7 [(gogoproto.nullable) = false]; optional uint64 commit = 8 [(gogoproto.nullable) = false]; + // hardState can be non-nil for MsgStorageAppend messages and is nil for all + // other message types. + optional HardState hardState = 13 [(gogoproto.nullable) = true]; // snapshot is non-nil and non-empty for MsgSnap messages and nil for all other // message types. However, peer nodes running older binary versions may send a // non-nil, empty value for the snapshot field of non-MsgSnap messages. Code @@ -86,7 +96,11 @@ message Message { optional Snapshot snapshot = 9 [(gogoproto.nullable) = true]; optional bool reject = 10 [(gogoproto.nullable) = false]; optional uint64 rejectHint = 11 [(gogoproto.nullable) = false]; - optional bytes context = 12; + optional bytes context = 12 [(gogoproto.nullable) = true]; + // responses are populated by a raft node to instruct storage threads on how + // to respond and who to respond to when the work associated with a message + // is complete. Populated for MsgStorageAppend and MsgStorageApply messages. + repeated Message responses = 14 [(gogoproto.nullable) = false]; } message HardState { diff --git a/raft/raftpb/raft_test.go b/raft/raftpb/raft_test.go index 7057446c223d..7f5be88b8d74 100644 --- a/raft/raftpb/raft_test.go +++ b/raft/raftpb/raft_test.go @@ -45,7 +45,7 @@ func TestProtoMemorySizes(t *testing.T) { assert(unsafe.Sizeof(s), if64Bit(144, 80), "Snapshot") var m Message - assert(unsafe.Sizeof(m), if64Bit(128, 92), "Message") + assert(unsafe.Sizeof(m), if64Bit(160, 108), "Message") var hs HardState assert(unsafe.Sizeof(hs), 24, "HardState")