Raft论文翻译(5.4.1)——安全性-选举限制

In any leader-based consensus algorithm, the leader must eventually store all of the committed log entries. In some consensus algorithms, such as Viewstamped Replication [22], a leader can be elected even if it doesn’t initially contain all of the committed entries.

These algorithms contain additional mechanisms to identify the missing entries and transmit them to the new leader, either during the election process or shortly afterwards. Unfortunately, this results in considerable additional mechanism and complexity.

Raft uses a simpler approach where it guarantees that all the committed entries from previous terms are present on each new leader from the moment of its election, without the need to transfer those entries to the leader. This means that log entries only flow in one direction, from leaders to followers, and leaders never overwrite existing entries in their logs.

在任何 leader-based 一致性算法中,leader必须最终存储所有committed 日志元素。在一些一致性算法中,例如Viewstamped Replication ,即使最初不包含所有提交的条目,也可以选举领导者。

这些算法包含额外的机制来识别丢失的条目并将它们传输给新的领导者,在选举过程中或之后不久。不幸的是,这会导致相当多的额外机制和复杂性。

Raft 使用一种更简单的方法,它保证从选举的那一刻起,每个新领导者都存在以前任期的所有已提交条目,无需将这些条目传输给领导者。这意味着日志条目仅沿一个方向流动,从领导者到追随者,而领导者永远不会覆盖其日志中的现有条目。

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. The RequestVote RPC implements this restriction: the RPC includes information about the candidate’s log, and the voter denies its vote if its own log is more up-to-date than that of the candidate.

Raft 使用投票流程去保证 候选人只有在它的 log 中包含所有已经提交的日志,才能从选举中胜出 。候选人请求投票的时候必须联系集群中的大部分节点。

如果候选人的日志至少与该多数人中的任何其他日志一样最新(“最新”在下面有明确定义),那么它将保存所有已提交的条目。

RequestVote RPC 实现了这个限制:

RPC 包含关于候选人日志的信息,

如果投票者自己的日志比候选人的日志更新,则投票者拒绝投票。

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.

Raft 通过比较日志中最后一个条目的索引和任期来确定两个日志中哪个是最新的。

如果日志的最后条目具有不同的term,则具有较晚term的日志是最新的。如果日志以相同term结尾,则日志较长的那个是最新的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值