Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve the problem that when changing the cluster configuration through the joint consensus algorithm, a new leader cannot be elected under abnormal circumstances. #432

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

walterzhaoJR
Copy link
Contributor

背景

假设有一个raft group有3个节点ABC,其中A是leader,现在通过联合共识将成员配置变更成ABD,当复制最新的配置(ABD)时,A节点退出,这条log只复制到了C节点(即将被移除的节点),此时集群将无法选举出新的leader。因为,选举成leader的必要条件是:存在最新的log(term大或者term相同的情况下,index更大)。当前的现状:只有C有最新的log,BD发起选举,C不会为他们投票。C发起选举的时候,按照目前的实现,C不在最新配置列表中,无法发起选举,此时集群将无法选举出新的leader。

解决方案

在查询了raft的论文后发现,并没有要求参与选举的节点一定要处于配置列表中,这个问题有点类似于原集群的leader不在新的配置列表中,当新配置commit后,原leader会stepdown。

请确认这个问题。

image

image

@walterzhaoJR walterzhaoJR changed the title remove _conf.contains check in pre_vote && elect_self Solve the problem that when changing the cluster configuration through the joint consensus algorithm, a new leader cannot be elected under abnormal circumstances. Dec 25, 2023
…s in conf during the pre_vote and elect_self processes.

2.Add reject_log_index_ to reject the raft log of a specific index on the follower, which is convenient for testing.
@walterzhaoJR walterzhaoJR force-pushed the allowe-elec-not-in-configuration-list branch from 3953a22 to 1b3a140 Compare January 6, 2024 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant