-
Hi there, while checking out Raft.go code I stumbled across this line where electionTimeOut is reset every time Candidate requests vote. In original Raft paper you are supposed to reset electionTimeout only if you granted vote, which makes sense, because outdated candidates (with different term, outdated log) can still call and timer is going to be reset even though they will never win the election. I was wondering whether I'm missing something or is this a mistake and there should be a PR with fix. https://github.com/nats-io/nats-server/blob/main/server/raft.go#L3918 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello @Vshishkar, thank you for bringing this up.
As you suggest, this could increase the time it takes to replace a failed leader. So overall, it's hard to say wether this is a net benefit or not. Depends on the situation. We are indeed not compliant to what the paper suggests (that is: reset for valid AppendEntry and granted VoteRequest). Personally, I agree we should change this to only reset the timer on granted vote. Please do send a PR if you want. But be aware that this part of the system is a bit in-flux right now, and we may not be able to take it as-is in the near future. We'll make sure to give you credit for pointing this out one way or another. |
Beta Was this translation helpful? Give feedback.
Hello @Vshishkar, thank you for bringing this up.
<pedantic>
the timer is reset every time a node receives a vote request (the cause of which is a candidate sending it out sometimes before)</pedantic>
.As you suggest, this could increase the time it takes to replace a failed leader.
However it could also result in less contention and interference when another candidate is trying to get elected.
So overall, it's hard to say wether this is a net benefit or not. Depends on the situation.
We are indeed not compliant to what the paper suggests (that is: reset for valid AppendEntry and granted VoteRequest).
But i hope we agree that th…