From 498d3fee4765f5309b23c085328c184722e15580 Mon Sep 17 00:00:00 2001 From: gladiator Date: Sat, 30 Sep 2017 17:39:10 +0800 Subject: [PATCH] raft: use learner instead of suffrage --- raft/node.go | 4 +- raft/progress.go | 9 +- raft/raft.go | 115 ++++++------ raft/raft_test.go | 56 +++--- raft/raftpb/raft.pb.go | 414 +++++++++++++---------------------------- raft/raftpb/raft.proto | 22 +-- raft/rawnode.go | 4 +- 7 files changed, 226 insertions(+), 398 deletions(-) diff --git a/raft/node.go b/raft/node.go index f124c3b25864..2895dbe588b0 100644 --- a/raft/node.go +++ b/raft/node.go @@ -334,8 +334,8 @@ func (n *node) run(r *raft) { switch cc.Type { case pb.ConfChangeAddNode: r.addNode(cc.NodeID) - case pb.ConfChangeAddNonvoter: - r.addNonvoter(cc.NodeID) + case pb.ConfChangeAddLearner: + r.addLearner(cc.NodeID) case pb.ConfChangeRemoveNode: // block incoming proposal when local node is // removed diff --git a/raft/progress.go b/raft/progress.go index 1425f91b6fe0..3c8555a1f6d0 100644 --- a/raft/progress.go +++ b/raft/progress.go @@ -14,11 +14,7 @@ package raft -import ( - "fmt" - - pb "github.com/coreos/etcd/raft/raftpb" -) +import "fmt" const ( ProgressStateProbe ProgressStateType = iota @@ -53,7 +49,6 @@ type Progress struct { // before and stops sending any replication message. State ProgressStateType - Suffrage pb.SuffrageState // Paused is used in ProgressStateProbe. // When Paused is true, raft should pause sending replication message to this peer. Paused bool @@ -82,6 +77,8 @@ type Progress struct { // be freed by calling inflights.freeTo with the index of the last // received entry. ins *inflights + + isLearner bool } func (pr *Progress) resetState(state ProgressStateType) { diff --git a/raft/raft.go b/raft/raft.go index 2afaaca83d3d..9602a3ad901c 100644 --- a/raft/raft.go +++ b/raft/raft.go @@ -114,7 +114,9 @@ type Config struct { // should only be set when starting a new raft cluster. Restarting raft from // previous configuration will panic if peers is set. peer is private and only // used for testing right now. - peers []pb.Server + peers []uint64 + + learners []uint64 // ElectionTick is the number of Node.Tick invocations that must pass between // elections. That is, if a follower does not receive any message from the @@ -235,10 +237,11 @@ type raft struct { maxInflight int maxMsgSize uint64 prs map[uint64]*Progress + learners map[uint64]*Progress state StateType - suffrage pb.SuffrageState + isLearner bool votes map[uint64]bool @@ -290,33 +293,22 @@ func newRaft(c *Config) *raft { if err != nil { panic(err) // TODO(bdarnell) } - peers := c.peers - if len(cs.Nodes) > 0 && len(cs.Servers) > 0 { - panic("cannot specify both ConfState.Nodes and ConfState.Servers") - } - if len(cs.Nodes) > 0 { - if len(peers) > 0 { + voters := c.peers + learners := c.learners + if len(cs.Nodes) > 0 || len(cs.Learners) > 0 { + if len(voters) > 0 || len(learners) > 0 { // TODO(bdarnell): the peers argument is always nil except in // tests; the argument should be removed and these tests should be // updated to specify their nodes through a snapshot. - panic("cannot specify both newRaft(peers) and ConfState.Nodes)") - } - for _, n := range cs.Nodes { - peers = append(peers, pb.Server{Node: n, Suffrage: pb.Voter}) - } - } - if len(cs.Servers) > 0 { - if len(peers) > 0 { - panic("cannot specify both newRaft(peers) and ConfState.Servers)") - } - for _, s := range cs.Servers { - peers = append(peers, *s) + panic("cannot specify both newRaft(peers, learners) and ConfState.(Nodes, Learners)") } + voters = cs.Nodes + learners = cs.Learners } r := &raft{ id: c.ID, lead: None, - suffrage: pb.Voter, + isLearner: false, raftLog: raftlog, maxMsgSize: c.MaxSizePerMsg, maxInflight: c.MaxInflightMsgs, @@ -329,10 +321,16 @@ func newRaft(c *Config) *raft { readOnly: newReadOnly(c.ReadOnlyOption), disableProposalForwarding: c.DisableProposalForwarding, } - for _, p := range peers { - r.prs[p.Node] = &Progress{Next: 1, ins: newInflights(r.maxInflight), Suffrage: p.Suffrage} - if r.id == p.Node { - r.suffrage = p.Suffrage + for _, n := range voters { + r.prs[n] = &Progress{Next: 1, ins: newInflights(r.maxInflight), isLearner: false} + } + for _, n := range learners { + if _, has := r.prs[n]; has { + panic(fmt.Sprintf("cannot specify both Voter and Learner for node: %x", n)) + } + r.prs[n] = &Progress{Next: 1, ins: newInflights(r.maxInflight), isLearner: true} + if r.id == n { + r.isLearner = true } } if !isHardStateEqual(hs, emptyState) { @@ -369,7 +367,7 @@ func (r *raft) hardState() pb.HardState { func (r *raft) voterCount() int { count := 0 for _, p := range r.prs { - if p.Suffrage == pb.Voter { + if !p.isLearner { count++ } } @@ -536,7 +534,7 @@ func (r *raft) maybeCommit() bool { // TODO(bmizerany): optimize.. Currently naive mis := make(uint64Slice, 0, r.voterCount()) for _, p := range r.prs { - if p.Suffrage == pb.Voter { + if !p.isLearner { mis = append(mis, p.Match) } } @@ -560,7 +558,7 @@ func (r *raft) reset(term uint64) { r.votes = make(map[uint64]bool) for id := range r.prs { - r.prs[id] = &Progress{Next: r.raftLog.lastIndex() + 1, ins: newInflights(r.maxInflight), Suffrage: r.prs[id].Suffrage} + r.prs[id] = &Progress{Next: r.raftLog.lastIndex() + 1, ins: newInflights(r.maxInflight), isLearner: r.prs[id].isLearner} if id == r.id { r.prs[id].Match = r.raftLog.lastIndex() } @@ -708,7 +706,7 @@ func (r *raft) campaign(t CampaignType) { if id == r.id { continue } - if r.prs[id].Suffrage != pb.Voter { + if r.prs[id].isLearner { continue } r.logger.Infof("%x [logterm: %d, index: %d] sent %s request to %x at term %d", @@ -1025,8 +1023,8 @@ func stepLeader(r *raft, m pb.Message) { } r.logger.Debugf("%x failed to send message to %x because it is unreachable [%s]", r.id, m.From, pr) case pb.MsgTransferLeader: - if pr.Suffrage != pb.Voter { - r.logger.Debugf("%x is not Voter. Ignored transferring leadership", r.id) + if pr.isLearner { + r.logger.Debugf("%x is Learner. Ignored transferring leadership", r.id) return } leadTransferee := m.From @@ -1210,64 +1208,57 @@ func (r *raft) restore(s pb.Snapshot) bool { r.raftLog.restore(s) r.prs = make(map[uint64]*Progress) - if len(s.Metadata.ConfState.Nodes) > 0 && len(s.Metadata.ConfState.Servers) > 0 { - panic("cannot specify both ConfState.Nodes and ConfState.Servers") - } - for _, n := range s.Metadata.ConfState.Nodes { + r.restoreNode(s.Metadata.ConfState.Nodes, false) + r.restoreNode(s.Metadata.ConfState.Learners, true) + return true +} + +func (r *raft) restoreNode(nodes []uint64, isLearner bool) { + for _, n := range nodes { match, next := uint64(0), r.raftLog.lastIndex()+1 if n == r.id { match = next - 1 - r.suffrage = pb.Voter + r.isLearner = isLearner } - r.setProgress(n, match, next, pb.Voter) + r.setProgress(n, match, next, isLearner) r.logger.Infof("%x restored progress of %x [%s]", r.id, n, r.prs[n]) } - for _, server := range s.Metadata.ConfState.Servers { - match, next := uint64(0), r.raftLog.lastIndex()+1 - if server.Node == r.id { - match = next - 1 - r.suffrage = server.Suffrage - } - r.setProgress(server.Node, match, next, server.Suffrage) - r.logger.Infof("%x restored progress of %x [%s]", r.id, server.Node, r.prs[server.Node]) - } - return true } // promotable indicates whether state machine can be promoted to leader, -// which is true when its own id is in progress list and suffrage is Voter +// which is true when its own id is in progress list and its not learner. func (r *raft) promotable() bool { _, ok := r.prs[r.id] - return ok && r.suffrage == pb.Voter + return ok && !r.isLearner } func (r *raft) addNode(id uint64) { - r.addNodeWithSuffrage(id, pb.Voter) + r.addLearnerNode(id, false) } -func (r *raft) addNonvoter(id uint64) { - r.addNodeWithSuffrage(id, pb.Nonvoter) +func (r *raft) addLearner(id uint64) { + r.addLearnerNode(id, true) } -func (r *raft) addNodeWithSuffrage(id uint64, suffrage pb.SuffrageState) { +func (r *raft) addLearnerNode(id uint64, isLearner bool) { r.pendingConf = false if _, ok := r.prs[id]; ok { - if r.prs[id].Suffrage == suffrage { + if r.prs[id].isLearner == isLearner { // Ignore any redundant addNode calls (which can happen because the // initial bootstrapping entries are applied twice). return } - if suffrage != pb.Voter { - // addNode can only change suffrage from Nonvoter to Voter + if isLearner { + // can only change Learner to Voter return } - r.prs[id].Suffrage = suffrage + r.prs[id].isLearner = isLearner } else { - r.setProgress(id, 0, r.raftLog.lastIndex()+1, suffrage) + r.setProgress(id, 0, r.raftLog.lastIndex()+1, isLearner) } if r.id == id { - r.suffrage = suffrage + r.isLearner = isLearner } // When a node is first added, we should mark it as recently active. // Otherwise, CheckQuorum may cause us to step down if it is invoked @@ -1297,8 +1288,8 @@ func (r *raft) removeNode(id uint64) { func (r *raft) resetPendingConf() { r.pendingConf = false } -func (r *raft) setProgress(id, match, next uint64, suffrage pb.SuffrageState) { - r.prs[id] = &Progress{Next: next, Match: match, ins: newInflights(r.maxInflight), Suffrage: suffrage} +func (r *raft) setProgress(id, match, next uint64, isLearner bool) { + r.prs[id] = &Progress{Next: next, Match: match, ins: newInflights(r.maxInflight), isLearner: isLearner} } func (r *raft) delProgress(id uint64) { @@ -1338,7 +1329,7 @@ func (r *raft) checkQuorumActive() bool { continue } - if r.prs[id].RecentActive && r.prs[id].Suffrage == pb.Voter { + if r.prs[id].RecentActive && !r.prs[id].isLearner { act++ } diff --git a/raft/raft_test.go b/raft/raft_test.go index ce14ed2d2dc5..cf6c35a36ffc 100644 --- a/raft/raft_test.go +++ b/raft/raft_test.go @@ -350,14 +350,14 @@ func testLeaderElection(t *testing.T, preVote bool) { func TestNonvoterElectionTimeout(t *testing.T) { n1 := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage()) - n1.prs[3].Suffrage = pb.Nonvoter + n1.prs[3].isLearner = true n2 := newTestRaft(2, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage()) - n2.prs[3].Suffrage = pb.Nonvoter + n2.prs[3].isLearner = true n3 := newTestRaft(3, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage()) - n3.suffrage = pb.Nonvoter - n3.prs[3].Suffrage = pb.Nonvoter + n3.isLearner = true + n3.prs[3].isLearner = true n1.becomeFollower(1, None) n2.becomeFollower(1, None) @@ -1106,7 +1106,7 @@ func TestCommit(t *testing.T) { sm := newTestRaft(1, []uint64{1}, 5, 1, storage) for j := 0; j < len(tt.matches); j++ { - sm.setProgress(uint64(j)+1, tt.matches[j], tt.matches[j]+1, pb.Voter) + sm.setProgress(uint64(j)+1, tt.matches[j], tt.matches[j]+1, false) } sm.maybeCommit() if g := sm.raftLog.committed; g != tt.w { @@ -2377,13 +2377,9 @@ func TestRestore(t *testing.T) { func TestRestoreWithNonvoter(t *testing.T) { s := pb.Snapshot{ Metadata: pb.SnapshotMetadata{ - Index: 11, // magic number - Term: 11, // magic number - ConfState: pb.ConfState{Servers: []*pb.Server{ - {Node: 1, Suffrage: pb.Voter}, - {Node: 2, Suffrage: pb.Voter}, - {Node: 3, Suffrage: pb.Nonvoter}, - }}, + Index: 11, // magic number + Term: 11, // magic number + ConfState: pb.ConfState{Nodes: []uint64{1, 2}, Learners: []uint64{3}}, }, } @@ -2399,9 +2395,18 @@ func TestRestoreWithNonvoter(t *testing.T) { if mustTerm(sm.raftLog.term(s.Metadata.Index)) != s.Metadata.Term { t.Errorf("log.lastTerm = %d, want %d", mustTerm(sm.raftLog.term(s.Metadata.Index)), s.Metadata.Term) } - for _, server := range s.Metadata.ConfState.Servers { - if sm.prs[server.Node].Suffrage != server.Suffrage { - t.Errorf("sm.Node %x suffrage = %s, want %s", server.Node, sm.prs[server.Node], server.Suffrage) + sg := sm.nodes() + if len(sg) != len(s.Metadata.ConfState.Nodes)+len(s.Metadata.ConfState.Learners) { + t.Errorf("sm.Nodes = %+v, length not equal with %+v", sg, s.Metadata.ConfState) + } + for _, n := range s.Metadata.ConfState.Nodes { + if sm.prs[n].isLearner { + t.Errorf("sm.Node %x isLearner = %s, want %t", n, sm.prs[n], true) + } + } + for _, n := range s.Metadata.ConfState.Learners { + if !sm.prs[n].isLearner { + t.Errorf("sm.Node %x isLearner = %s, want %t", n, sm.prs[n], false) } } @@ -2656,7 +2661,7 @@ func TestAddNode(t *testing.T) { func TestAddNonvoter(t *testing.T) { r := newTestRaft(1, []uint64{1}, 10, 1, NewMemoryStorage()) r.pendingConf = true - r.addNonvoter(2) + r.addLearner(2) if r.pendingConf { t.Errorf("pendingConf = %v, want false", r.pendingConf) } @@ -2665,8 +2670,8 @@ func TestAddNonvoter(t *testing.T) { if !reflect.DeepEqual(nodes, wnodes) { t.Errorf("nodes = %v, want %v", nodes, wnodes) } - if r.prs[2].Suffrage != pb.Nonvoter { - t.Fatalf("node 2 has suffrage %s, want %s", r.prs[2].Suffrage, pb.Nonvoter) + if !r.prs[2].isLearner { + t.Fatalf("node 2 has suffrage %t, want %t", r.prs[2].isLearner, true) } } @@ -3439,14 +3444,17 @@ func newNetworkWithConfig(configFunc func(*Config), peers ...stateMachine) *netw sm := newRaft(cfg) npeers[id] = sm case *raft: - suffrages := make(map[uint64]pb.SuffrageState, size) + learners := make(map[uint64]bool, 0) for i, pr := range p.(*raft).prs { - suffrages[i] = pr.Suffrage + if pr.isLearner { + learners[i] = true + } } v.id = id v.prs = make(map[uint64]*Progress) for i := 0; i < size; i++ { - v.prs[peerAddrs[i]] = &Progress{Suffrage: suffrages[peerAddrs[i]]} + _, isLearner := learners[peerAddrs[i]] + v.prs[peerAddrs[i]] = &Progress{isLearner: isLearner} } v.reset(v.Term) npeers[id] = v @@ -3553,13 +3561,9 @@ func setRandomizedElectionTimeout(r *raft, v int) { } func newTestConfig(id uint64, peers []uint64, election, heartbeat int, storage Storage) *Config { - new_peers := make([]pb.Server, 0) - for _, p := range peers { - new_peers = append(new_peers, pb.Server{Node: p, Suffrage: pb.Voter}) - } return &Config{ ID: id, - peers: new_peers, + peers: peers, ElectionTick: election, HeartbeatTick: heartbeat, Storage: storage, diff --git a/raft/raftpb/raft.pb.go b/raft/raftpb/raft.pb.go index 5341d9bf7300..9830ca65426f 100644 --- a/raft/raftpb/raft.pb.go +++ b/raft/raftpb/raft.pb.go @@ -14,7 +14,6 @@ Snapshot Message HardState - Server ConfState ConfChange */ @@ -160,60 +159,26 @@ func (x *MessageType) UnmarshalJSON(data []byte) error { } func (MessageType) EnumDescriptor() ([]byte, []int) { return fileDescriptorRaft, []int{1} } -type SuffrageState int32 - -const ( - Nonvoter SuffrageState = 0 - Voter SuffrageState = 1 -) - -var SuffrageState_name = map[int32]string{ - 0: "Nonvoter", - 1: "Voter", -} -var SuffrageState_value = map[string]int32{ - "Nonvoter": 0, - "Voter": 1, -} - -func (x SuffrageState) Enum() *SuffrageState { - p := new(SuffrageState) - *p = x - return p -} -func (x SuffrageState) String() string { - return proto.EnumName(SuffrageState_name, int32(x)) -} -func (x *SuffrageState) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(SuffrageState_value, data, "SuffrageState") - if err != nil { - return err - } - *x = SuffrageState(value) - return nil -} -func (SuffrageState) EnumDescriptor() ([]byte, []int) { return fileDescriptorRaft, []int{2} } - type ConfChangeType int32 const ( - ConfChangeAddNode ConfChangeType = 0 - ConfChangeRemoveNode ConfChangeType = 1 - ConfChangeUpdateNode ConfChangeType = 2 - ConfChangeAddNonvoter ConfChangeType = 3 + ConfChangeAddNode ConfChangeType = 0 + ConfChangeRemoveNode ConfChangeType = 1 + ConfChangeUpdateNode ConfChangeType = 2 + ConfChangeAddLearner ConfChangeType = 3 ) var ConfChangeType_name = map[int32]string{ 0: "ConfChangeAddNode", 1: "ConfChangeRemoveNode", 2: "ConfChangeUpdateNode", - 3: "ConfChangeAddNonvoter", + 3: "ConfChangeAddLearner", } var ConfChangeType_value = map[string]int32{ - "ConfChangeAddNode": 0, - "ConfChangeRemoveNode": 1, - "ConfChangeUpdateNode": 2, - "ConfChangeAddNonvoter": 3, + "ConfChangeAddNode": 0, + "ConfChangeRemoveNode": 1, + "ConfChangeUpdateNode": 2, + "ConfChangeAddLearner": 3, } func (x ConfChangeType) Enum() *ConfChangeType { @@ -232,7 +197,7 @@ func (x *ConfChangeType) UnmarshalJSON(data []byte) error { *x = ConfChangeType(value) return nil } -func (ConfChangeType) EnumDescriptor() ([]byte, []int) { return fileDescriptorRaft, []int{3} } +func (ConfChangeType) EnumDescriptor() ([]byte, []int) { return fileDescriptorRaft, []int{2} } type Entry struct { Term uint64 `protobuf:"varint,2,opt,name=Term" json:"Term"` @@ -303,27 +268,16 @@ func (m *HardState) String() string { return proto.CompactTextString( func (*HardState) ProtoMessage() {} func (*HardState) Descriptor() ([]byte, []int) { return fileDescriptorRaft, []int{4} } -type Server struct { - Node uint64 `protobuf:"varint,1,opt,name=node" json:"node"` - Suffrage SuffrageState `protobuf:"varint,2,opt,name=suffrage,enum=raftpb.SuffrageState" json:"suffrage"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Server) Reset() { *m = Server{} } -func (m *Server) String() string { return proto.CompactTextString(m) } -func (*Server) ProtoMessage() {} -func (*Server) Descriptor() ([]byte, []int) { return fileDescriptorRaft, []int{5} } - type ConfState struct { - Nodes []uint64 `protobuf:"varint,1,rep,name=nodes" json:"nodes,omitempty"` - Servers []*Server `protobuf:"bytes,2,rep,name=servers" json:"servers,omitempty"` - XXX_unrecognized []byte `json:"-"` + Nodes []uint64 `protobuf:"varint,1,rep,name=nodes" json:"nodes,omitempty"` + Learners []uint64 `protobuf:"varint,2,rep,name=learners" json:"learners,omitempty"` + XXX_unrecognized []byte `json:"-"` } func (m *ConfState) Reset() { *m = ConfState{} } func (m *ConfState) String() string { return proto.CompactTextString(m) } func (*ConfState) ProtoMessage() {} -func (*ConfState) Descriptor() ([]byte, []int) { return fileDescriptorRaft, []int{6} } +func (*ConfState) Descriptor() ([]byte, []int) { return fileDescriptorRaft, []int{5} } type ConfChange struct { ID uint64 `protobuf:"varint,1,opt,name=ID" json:"ID"` @@ -336,7 +290,7 @@ type ConfChange struct { func (m *ConfChange) Reset() { *m = ConfChange{} } func (m *ConfChange) String() string { return proto.CompactTextString(m) } func (*ConfChange) ProtoMessage() {} -func (*ConfChange) Descriptor() ([]byte, []int) { return fileDescriptorRaft, []int{7} } +func (*ConfChange) Descriptor() ([]byte, []int) { return fileDescriptorRaft, []int{6} } func init() { proto.RegisterType((*Entry)(nil), "raftpb.Entry") @@ -344,12 +298,10 @@ func init() { proto.RegisterType((*Snapshot)(nil), "raftpb.Snapshot") proto.RegisterType((*Message)(nil), "raftpb.Message") proto.RegisterType((*HardState)(nil), "raftpb.HardState") - proto.RegisterType((*Server)(nil), "raftpb.Server") proto.RegisterType((*ConfState)(nil), "raftpb.ConfState") proto.RegisterType((*ConfChange)(nil), "raftpb.ConfChange") proto.RegisterEnum("raftpb.EntryType", EntryType_name, EntryType_value) proto.RegisterEnum("raftpb.MessageType", MessageType_name, MessageType_value) - proto.RegisterEnum("raftpb.SuffrageState", SuffrageState_name, SuffrageState_value) proto.RegisterEnum("raftpb.ConfChangeType", ConfChangeType_name, ConfChangeType_value) } func (m *Entry) Marshal() (dAtA []byte, err error) { @@ -567,33 +519,6 @@ func (m *HardState) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *Server) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Server) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - dAtA[i] = 0x8 - i++ - i = encodeVarintRaft(dAtA, i, uint64(m.Node)) - dAtA[i] = 0x10 - i++ - i = encodeVarintRaft(dAtA, i, uint64(m.Suffrage)) - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) - } - return i, nil -} - func (m *ConfState) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -616,16 +541,11 @@ func (m *ConfState) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintRaft(dAtA, i, uint64(num)) } } - if len(m.Servers) > 0 { - for _, msg := range m.Servers { - dAtA[i] = 0x12 + if len(m.Learners) > 0 { + for _, num := range m.Learners { + dAtA[i] = 0x10 i++ - i = encodeVarintRaft(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n + i = encodeVarintRaft(dAtA, i, uint64(num)) } } if m.XXX_unrecognized != nil { @@ -783,17 +703,6 @@ func (m *HardState) Size() (n int) { return n } -func (m *Server) Size() (n int) { - var l int - _ = l - n += 1 + sovRaft(uint64(m.Node)) - n += 1 + sovRaft(uint64(m.Suffrage)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - func (m *ConfState) Size() (n int) { var l int _ = l @@ -802,10 +711,9 @@ func (m *ConfState) Size() (n int) { n += 1 + sovRaft(uint64(e)) } } - if len(m.Servers) > 0 { - for _, e := range m.Servers { - l = e.Size() - n += 1 + l + sovRaft(uint64(l)) + if len(m.Learners) > 0 { + for _, e := range m.Learners { + n += 1 + sovRaft(uint64(e)) } } if m.XXX_unrecognized != nil { @@ -1636,95 +1544,6 @@ func (m *HardState) Unmarshal(dAtA []byte) error { } return nil } -func (m *Server) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRaft - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Server: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Server: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Node", wireType) - } - m.Node = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRaft - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Node |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Suffrage", wireType) - } - m.Suffrage = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRaft - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Suffrage |= (SuffrageState(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipRaft(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthRaft - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *ConfState) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1817,36 +1636,67 @@ func (m *ConfState) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: wrong wireType = %d for field Nodes", wireType) } case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Servers", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRaft + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRaft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } } - if iNdEx >= l { + m.Learners = append(m.Learners, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRaft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthRaft + } + postIndex := iNdEx + packedLen + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRaft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.Learners = append(m.Learners, v) } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Learners", wireType) } - if msglen < 0 { - return ErrInvalidLengthRaft - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Servers = append(m.Servers, &Server{}) - if err := m.Servers[len(m.Servers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipRaft(dAtA[iNdEx:]) @@ -2116,60 +1966,56 @@ var ( func init() { proto.RegisterFile("raft.proto", fileDescriptorRaft) } var fileDescriptorRaft = []byte{ - // 871 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x54, 0x4d, 0x6f, 0xe3, 0x44, - 0x18, 0x8e, 0x13, 0xe7, 0xeb, 0x4d, 0x9a, 0x4e, 0xdf, 0x4d, 0xd1, 0xb0, 0x5a, 0x85, 0x28, 0xe2, - 0x10, 0x15, 0x6d, 0x81, 0x1c, 0x40, 0xe2, 0xb6, 0x6d, 0x91, 0x5a, 0x41, 0xaa, 0xc5, 0xed, 0xee, - 0x01, 0x84, 0xd0, 0x34, 0x9e, 0xb8, 0x81, 0xda, 0x63, 0xcd, 0x4c, 0xca, 0xee, 0x05, 0xf1, 0x03, - 0xf8, 0x01, 0x5c, 0xf8, 0x3f, 0x3d, 0xae, 0xc4, 0x1d, 0xb1, 0xe5, 0x8f, 0xa0, 0x19, 0x8f, 0x1d, - 0x3b, 0xb9, 0xcd, 0x3c, 0xcf, 0xeb, 0xe7, 0x7d, 0xde, 0x0f, 0x0f, 0x80, 0x64, 0x4b, 0x7d, 0x9c, - 0x4a, 0xa1, 0x05, 0xb6, 0xcc, 0x39, 0xbd, 0x79, 0x3a, 0x8c, 0x44, 0x24, 0x2c, 0xf4, 0xa9, 0x39, - 0x65, 0xec,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f2, 0xde, 0x3d, 0x8e, - 0xbc, 0x7f, 0x1f, 0x47, 0xde, 0x9f, 0xff, 0x8d, 0x6a, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0x10, - 0x3a, 0xce, 0xfa, 0x06, 0x07, 0x00, 0x00, + // 813 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x54, 0xcd, 0x8e, 0xe3, 0x44, + 0x10, 0x8e, 0x1d, 0xe7, 0xaf, 0x9c, 0xc9, 0xf4, 0xf4, 0x06, 0xd4, 0x1a, 0xad, 0x42, 0x14, 0x71, + 0x88, 0x06, 0xed, 0x00, 0x73, 0xe0, 0x80, 0xc4, 0x61, 0x26, 0x41, 0x9a, 0x48, 0x9b, 0xd1, 0x92, + 0xcd, 0x72, 0x40, 0x42, 0xa8, 0x27, 0xae, 0x38, 0x81, 0xd8, 0x6d, 0xb5, 0x3b, 0xcb, 0xee, 0x05, + 0xf1, 0x00, 0x3c, 0x00, 0x17, 0xde, 0x67, 0x8e, 0x2b, 0x71, 0x47, 0xcc, 0xf0, 0x22, 0xa8, 0xdb, + 0xed, 0xc4, 0x4e, 0x6e, 0x5d, 0xdf, 0x57, 0x5d, 0xf5, 0xd5, 0xd7, 0x65, 0x03, 0x48, 0xbe, 0x54, + 0x97, 0x89, 0x14, 0x4a, 0xd0, 0xba, 0x3e, 0x27, 0xf7, 0xe7, 0xdd, 0x50, 0x84, 0xc2, 0x40, 0x9f, + 0xeb, 0x53, 0xc6, 0x0e, 0x7e, 0x83, 0xda, 0xb7, 0xb1, 0x92, 0xef, 0xe9, 0x67, 0xe0, 0xcd, 0xdf, + 0x27, 0xc8, 0x9c, 0xbe, 0x33, 0xec, 0x5c, 0x9d, 0x5d, 0x66, 0xb7, 0x2e, 0x0d, 0xa9, 0x89, 0x1b, + 0xef, 0xe1, 0x9f, 0x4f, 0x2a, 0x33, 0x93, 0x44, 0x19, 0x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x11, 0x8a, 0xad, 0xba, 0x13, 0xbf, 0x92, + 0x8e, 0x15, 0x33, 0x43, 0x1e, 0x98, 0x9f, 0x21, 0x39, 0xb5, 0x62, 0x76, 0x88, 0x11, 0x43, 0xec, + 0xbc, 0xaf, 0x24, 0x9a, 0x11, 0xcf, 0x6c, 0x57, 0x1b, 0x9b, 0x1c, 0x7a, 0xb1, 0x85, 0x4e, 0xf9, + 0x79, 0xb5, 0x8e, 0x3d, 0x72, 0x1d, 0x04, 0xfa, 0x2d, 0x49, 0x85, 0x32, 0xe8, 0xee, 0xe1, 0x19, + 0x46, 0xe2, 0x2d, 0x1a, 0xc6, 0x29, 0x33, 0x6f, 0x92, 0x80, 0xab, 0x8c, 0x71, 0xcb, 0xcc, 0x75, + 0x10, 0xbc, 0xcc, 0xb6, 0x91, 0x54, 0x6f, 0xd8, 0xc3, 0x63, 0xaf, 0xf2, 0xe1, 0xb1, 0x57, 0x79, + 0x78, 0xea, 0x39, 0x1f, 0x9e, 0x7a, 0xce, 0xbf, 0x4f, 0x3d, 0xe7, 0xcf, 0xff, 0x7a, 0x95, 0xff, + 0x03, 0x00, 0x00, 0xff, 0xff, 0x3f, 0x1a, 0xcf, 0x3b, 0x70, 0x06, 0x00, 0x00, } diff --git a/raft/raftpb/raft.proto b/raft/raftpb/raft.proto index da1afbabf200..3ee8c0cfc89b 100644 --- a/raft/raftpb/raft.proto +++ b/raft/raftpb/raft.proto @@ -75,26 +75,16 @@ message HardState { optional uint64 commit = 3 [(gogoproto.nullable) = false]; } -enum SuffrageState { - Nonvoter = 0; - Voter = 1; -} - -message Server { - optional uint64 node = 1 [(gogoproto.nullable) = false]; - optional SuffrageState suffrage = 2 [(gogoproto.nullable) = false]; -} - message ConfState { - repeated uint64 nodes = 1; - repeated Server servers = 2; + repeated uint64 nodes = 1; // Voters + repeated uint64 learners = 2; // Nonvoters } enum ConfChangeType { - ConfChangeAddNode = 0; - ConfChangeRemoveNode = 1; - ConfChangeUpdateNode = 2; - ConfChangeAddNonvoter = 3; + ConfChangeAddNode = 0; + ConfChangeRemoveNode = 1; + ConfChangeUpdateNode = 2; + ConfChangeAddLearner = 3; } message ConfChange { diff --git a/raft/rawnode.go b/raft/rawnode.go index a89ae4c80a9b..b0208e64651c 100644 --- a/raft/rawnode.go +++ b/raft/rawnode.go @@ -175,8 +175,8 @@ func (rn *RawNode) ApplyConfChange(cc pb.ConfChange) *pb.ConfState { switch cc.Type { case pb.ConfChangeAddNode: rn.raft.addNode(cc.NodeID) - case pb.ConfChangeAddNonvoter: - rn.raft.addNonvoter(cc.NodeID) + case pb.ConfChangeAddLearner: + rn.raft.addLearner(cc.NodeID) case pb.ConfChangeRemoveNode: rn.raft.removeNode(cc.NodeID) case pb.ConfChangeUpdateNode: