前言
raft 論文斷斷續(xù)續(xù)看了好久了流济, etcd的raft實(shí)現(xiàn)也是斷斷續(xù)續(xù)看了好久锐锣, 最近又想起了,再回顧的時(shí)候發(fā)現(xiàn)好多細(xì)節(jié)又是忘了绳瘟, 還是做些簡(jiǎn)單記錄吧雕憔,記性不好還不肯動(dòng)筆,那就完蛋了..
progress
progress 是leader維護(hù)的各個(gè)follower的狀態(tài)信息糖声, 總共有三種狀態(tài): probe
, replicate
, snapshot
斤彼, 其內(nèi)部的狀態(tài)機(jī)如下轉(zhuǎn)換
+--------------------------------------------------------+
| send snapshot |
| |
+---------+----------+ +----------v---------+
+---> probe | | snapshot |
| | max inflight = 1 <----------------------------------+ max inflight = 0 |
| +---------+----------+ +--------------------+
| | 1. snapshot success
| | (next=snapshot.index + 1)
| | 2. snapshot failure
| | (no change)
| | 3. receives msgAppResp(rej=false&&index>lastsnap.index)
| | (match=m.index,next=match+1)
receives msgAppResp(rej=true)
(next=match+1)| |
| |
| |
| | receives msgAppResp(rej=false&&index>match)
| | (match=m.index,next=match+1)
| |
| |
| |
| +---------v----------+
| | replicate |
+---+ max inflight = n |
+--------------------+
raft 的membership change 一點(diǎn)小區(qū)別.
etcd的實(shí)現(xiàn)
The key invariant that membership changes happen one node at a time is preserved, but in our implementation the membership change takes effect when its entry is applied, not when it is added to the log (so the entry is committed under the old membership instead of the new)
raft 論文的論述
once a given server adds the lastest configuation entry to its log. it uses the the latest configuration in its log. regardless of whether the entry is commited.... This means that the leader will use the rules of Cnew.new to determine when the log entry for Cnew.old is committed