首页 > 解决方案 > 在 Raft 中,follower 何时知道条目已提交?Can an out-of-date node can win a election?

问题描述

在 raft 中,如果日志复制到多数,则认为它已在领导者中提交。然后leader发送msg给follower,告诉follower一个entry变为commit。如果没有,follower如何以及何时知道一个entry变为commit?

Another question,if an out of date can win an election in the following case? 5个节点集群,节点A是当前leader。

答: 0 1 2 3 4

乙: 0 1 2 3 4

C: 0 1 2 3 4

D: 0 1 2 3

E: 0 1

当节点 A(当前领导者)收到请求(条目 4)时,将其记录并复制到节点 B 和节点 C。然后节点 A 在状态机中应用条目 4 并回复客户端(此时条目被认为已由节点提交B 和节点 C 与否?)。Then node A and node B crash, node D start new election vote itself and get vote by node E, then win the election . 这种情况会发生吗?

标签: consensusraftleader

解决方案


领导者发送给追随者的 AppendEntries RPC 包括提交索引,当追随者从领导者那里收到这些日志条目时,他们可以将这些日志条目应用到他们的状态机。Follows 只会从领导者那里得到一个提交索引,它自己从不计算它。如果领导者失败,新领导者将计算相关的提交索引并将其与 AppendEntries RPC 调用一起发送。

For the election question, D can't win the election, it needs 3 votes to win, and it'll not get a vote from C. Eventually C will start an election and win it and continue as leader.


推荐阅读