Raft:如果分区的话term会一直增加吗?
分区服务器会一直增加term吗? 如果是这样,我又会感到困惑。
raft paper第3.6章(安全)说:
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.
这让我想到了这样一个场景:来自分区网络的一台服务器因为期限过长而赢得选举,然后导致不一致。会发生这种情况吗?
Will the partitioned server increase term all the time?
If so, I get another confusion.
Chapter 3.6 (safety) in raft paper says:
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.
It got me thinking about a scenario when one server from a partitioned network win the election because of the huge term, then causing the unconsistency. Will that happens?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑部分:
当任期较大的节点重新加入集群时,将迫使当前领导者下台。当leader向follower发送请求并且follower有较大的term时;追随者拒绝请求,领导者看到更大的术语;这迫使领导人下台并进行新的选举。
一些 raft 实现在追随者成为候选者之前有一个额外的步骤 - 如果追随者没有收到领导者的消息,追随者会尝试连接其他追随者;如果达到法定人数,那么追随者就成为候选人。
(我读了你的链接),是的,实施可能会不断增加这个术语;或者更实际一点,等到获得多数票——如果没有获得多数票,就没有必要发起选举。
我决定发表评论是因为你的问题中的这句话“因为任期大而赢得选举”。很久以前,当我阅读 raft paper (https://raft.github.io/raft.pdf< /a>),我对选举过程感到非常困惑。
第5.2节讨论领导者选举;它有这样的文字“每个服务器将在一个选举中最多投票给一名候选人
给定期限,按照先到先得的原则(注意:第 5.4 节添加了对投票的额外限制)。”
第 5.4 节 “前面的部分描述了 Raft 如何选举领导者并复制日志条目。然而,这些机制
到目前为止所描述的还不足以确保每个
状态机执行完全相同的命令
相同的顺序...”
基本上,如果读者逐节阅读论文,并在每一节之后停下来思考,那么读者会有点困惑。至少我是:)
作为一般结论:新术语绝对值没有任何区别,它用于拒绝旧术语,但对于实际的领导者选举(以及新术语的开始),真正重要的是日志的状态。
Edit part:
When a node with larger term rejoins the cluster, that will force the current leader to step down. When a leader sends request to a follower and the follower has larger term; the follower rejects the request and the leader sees larger term; that forces the leader to step down and new election will happen.
Some raft implementations have an extra step before a follower becomes candidate - if a follower does not hear from the leader, the follower tries to connect other followers; and if there is a quorum, then the follower becomes a candidate.
(I read your link), and yes, an implementation may keep increasing the term; or be more practical and wait till majority is reachable - there is no point to initiate an election if no majority is available.
I decided to comment because of this line in your question "win the election because of the huge term". Long time ago, when I read raft paper (https://raft.github.io/raft.pdf), I was quite confused by the election process.
Section 5.2 talks about leader election; and it has these words "Each server will vote for at most one candidate in a
given term, on a first-come-first-served basis (note: Section 5.4 adds an additional restriction on votes)."
Section 5.4 "The previous sections described how Raft elects leaders and replicates log entries. However, the mechanisms
described so far are not quite sufficient to ensure that each
state machine executes exactly the same commands in the
same order..."
Basically if a reader reads the paper section by section, and stops to think after each of them, then the reader will be a bit confused. At least I was :)
As a general conclusion: new term absolute value does not make any difference. It is used to reject older terms. But for actual leader election (and new term being started) it's the state of the log what actually matters.