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
walterzhaoJR wants to merge 1 commit intobaidu:masterfrom
Conversation
…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.
3953a22 to
1b3a140
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
假设有一个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。
请确认这个问题。