抛出原论文:
Raft uses the voting process to prevent a candidate from winning an election unless its log contains all committed entries. A candidate must contact a majority of the cluster in order to be elected, which means that every committed entry must be present in at least one of those servers. If the candidate ’ s log is at least as up-to-date as any other log in that majority (where “ up-to-date ” is defined precisely below), then it will hold all the committed entries... 这是说,leader 必须包含所有已提交的日志,那么选择时候选节点必须是 up-to-date
的。
Raft determines which of two logs is more up-to-date by comparing the index and term of the last entries in the logs. If the logs have last entries with different terms, then the log with the later term is more up-to-date. If the logs end with the same term, then whichever log is longer is more up-to-date. 这是说,判断 up-to-date
的标准是,term 号越大越新; term 号一致则日志越长越新。
我想问下,满足这个 up-to-date
标准,为什么该候选节点就包含了所有的已提交日志了?
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.