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

感觉Node判断是否选举是否有点问题 #2

Open
zyhnjust opened this issue Jul 3, 2019 · 3 comments
Open

感觉Node判断是否选举是否有点问题 #2

zyhnjust opened this issue Jul 3, 2019 · 3 comments

Comments

@zyhnjust
Copy link

zyhnjust commented Jul 3, 2019

看了下代码。 Node 如果是follower, 当判断是否要选举的时候, 首先判断了一下自己是否是leader, 如果不是就继续判断是否过了选举时间, 过了就开始选举。
我猜测应该是heartbeat的时候应该延长这个要选择leader的时间, 但是没有看到代码里有判断。
当然这样运行也不会错, 但是多了很多无效的选举。 不知道说的对不?

@Zouxxyy
Copy link

Zouxxyy commented Apr 23, 2020

我觉得你说的对

解决办法是:在收到心跳或者投票给别人后,都将 preElectionTime 设为当前时间,达到延长的效果

@xiedi-w
Copy link

xiedi-w commented Aug 14, 2022

心跳请求也是追加日志rpc一种,作者在追加日志处理中重置了上一次选举的时间。见defaultConsensus#appendEntries

@ningyixi
Copy link

哪位大佬能教教我这里面Leader选举的时候,防止分裂选举是怎么实现的

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

No branches or pull requests

4 participants