筏如何处理上一个提交的条目? [英] How does raft handle committing entries from previous one?

查看:97
本文介绍了筏如何处理上一个提交的条目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在木筏



S5 当选为领导者时,它仅查看其当前已提交的日志(term3,index1),这将覆盖 term2 所有关注者中的条目。



让领导者查看自己提交的日志如何解决该问题?

解决方案

阅读此图片上的标题。 (d)和(e)都是对(a),(b)和(c)生成的日志状态的可能解决方案。问题是,即使在(c)中将条目(2,2)复制到了大多数集群,这也说明,当在(d)中选择S5时,它仍可能被覆盖。因此,解决方案是仅允许节点按照自己的条件提交条目。换句话说,在大多数节点上复制条目不会等同承诺。在(c)中,条目(2,2)被复制到集群的大多数中,但是由于它不在领导者的任职范围内(至少4个),因此未提交。但是在(e)中,领导者从其当前任期(4)复制了一个条目后,由于(S5)不能再当选为领导者,这阻止了(d)中的情况发生。


In raft paper section 5.4.2

If a leader crashes before committing an entry, future leaders will attempt to finish replicating the entry. However, a leader cannot immediately conclude that an entry from a previous term is committed once it is stored on a majority of servers. There could be a situation where an old log entry is stored on a majority of servers, yet can still be overwritten by a future leader.

The author mentioned that to avoid the situation above

To eliminate problems like the one in Figure 8, Raft never commits log entries from previous terms by counting replicas. Only log entries from the leader’s current term are committed by counting replicas; once an entry from the current term has been committed in this way, then all prior entries are committed indirectly because of the Log Matching Property.

But wouldn't the same problem still occur?

Given the following situation that the author provided

When S5 is elected leader it only looks at its current committed log which is (term3, index1) and this is going to override term2 entries in all followers.

How does making a leader looking at its own committed log solve the problem?

解决方案

Read the caption on this image. Both (d) and (e) are possible resolutions to the state of the log produced by (a), (b), and (c). The problem is, even though in (c) entry (2, 2) was replicated to a majority of the cluster, this is illustrating that it could still be overwritten when S5 is elected in (d). So, the solution is to only allow nodes to commit entries from their own term. In other words, replicating an entry on a majority of nodes does not equal commitment. In (c), entry (2, 2) is replicated to a majority of the cluster, but because it's not in the leader's term (at least 4) it's not committed. But in (e), after the leader replicates an entry from its current term (4), that prevents the situation in (d) from occurring since S5 can no longer be elected leader.

这篇关于筏如何处理上一个提交的条目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆