raft: add conf safety

To make configuration change safe without adding configuration protocol:

1. We only allow to add/remove one node at a time.

2. We only allow one uncommitted configuration entry in the log.

These two rules can make sure there is no disjoint quorums in both current cluster and the
future(after applied any number of committed entries or uncommitted entries in log) clusters.

We add a type field in Entry structure for two reasons:

1. Statemachine needs to know if there is a pending configuration change.

2. Configuration entry should be executed by raft package rather application who is using raft.
This commit is contained in:
Xiang Li
2014-06-05 13:00:18 -07:00
committed by Yicheng Qin
parent 853a458a0d
commit c03fbf68d6
4 changed files with 62 additions and 16 deletions

View File

@@ -33,7 +33,7 @@ func New(addr int, peer []int, heartbeat, election tick) *Node {
// Propose asynchronously proposes data be applied to the underlying state machine.
func (n *Node) Propose(data []byte) {
m := Message{Type: msgProp, Data: data}
m := Message{Type: msgProp, Entries: []Entry{{Data: data}}}
n.Step(m)
}