Skip to content

Commit

Permalink
Add: cn version of raft-leader-step-down
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer committed Dec 18, 2023
1 parent 02ef1c1 commit 8b2e96b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This repo is a list of distributed consensus protocol's bugs, flaws, deceptive t
- [Paxos: (Optimize): Asymmetric Acceptors](src/list/asymmetric-paxos/asymmetric-paxos.md) | 🌎 [中文版](src/list/asymmetric-paxos/asymmetric-paxos.cn.md)
- [Paxos/Raft: (Generalize): Round Number Reversion](src/list/paxos-revert-rnd/paxos-revert-rnd.md) | 🌎 [中文版](src/list/paxos-revert-rnd/paxos-revert-rnd.cn.md)
- [Paxos: (Generalize): Partial Order Round Number = Paxos + 2PC](src/list/paxos-partial-order-rnd/paxos-partial-order-rnd.md) | 🌎 [中文版](src/list/paxos-partial-order-rnd/paxos-partial-order-rnd.cn.md)
- [Raft: (Suboptimal): Leader Step Down](src/list/raft-leader-step-down/raft-leader-step-down.md)
- [Raft: (Suboptimal): Leader Step Down](src/list/raft-leader-step-down/raft-leader-step-down.md) | 🌎 [中文版](src/list/raft-leader-step-down/raft-leader-step-down.cn.md)
- [Raft: (Optimize): ReadIndex: Less Wait](src/list/raft-read-index/raft-read-index.md) | 🌎 [中文版](src/list/raft-read-index/raft-read-index.cn.md)


Expand Down
33 changes: 33 additions & 0 deletions src/list/raft-leader-step-down/raft-leader-step-down.cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Raft: (Suboptimal): Leader Step Down

> 在raft论文中:
> 6. Cluster membership changes
>
> 第二个问题是集群 Leader 可能不在新配置中。
> 在这种情况下,一旦 Leader 提交了 $C_{new}$ 日志条目,它就会退位(返回到追随者状态)。
>
> ![](raft-leader-step-down-std.jpeg)
但是 Leader **不必** 立刻放弃领导权:

尽管它 **不应该**为其他 Candidate 投票,一个 Learner (也称为 Non-voter,从集群配置中移除的节点)仍然可以保持 Leader 地位(或成为 Candidate ),只要它愿意。这种不投票的 Leader :

- 与正常 Leader 一样处理写操作,除了本地日志存储不计入 quorum。
- 与正常 Leader 一样处理读操作。

**注意**: Learner (Non-voter)也不必拒绝来自其他节点的投票请求。
因为raft确保使用倒数第二个已提交配置的 Candidate 永远不会成为 Leader 。Thanks to [Gao Xinge](https://www.zhihu.com/people/gao-xinge).

![](raft-leader-step-down-optimize.jpeg)

### 改进

当 Leader 提交 $C_{new}$ 时,它 **不会** 放弃 leadership,但会继续作为 Leader 服务。

通过这种方式,membership config 日志不需要被实现特别处理。只有在需要时才会移除(non-voting) Leader :
通过关闭非投票 Leader 或通知其将领导权转移给另一个节点。


**参考文献**

- [Raft consensus algorithm](https://raft.github.io/)
2 changes: 1 addition & 1 deletion src/list/raft-leader-step-down/raft-leader-step-down.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ would never become the leader. Thanks to [Gao Xinge](https://www.zhihu.com/peopl

![](raft-leader-step-down-optimize.jpeg)

#### Improvement
### Improvement

When a leader commits $C_{new}$, it does **NOT** give up leadership, but just
keep serving as leader.
Expand Down

0 comments on commit 8b2e96b

Please sign in to comment.