raft-rs
raft-rs copied to clipboard
*: introduce judge_split_prevote
During split prevote, a campaign will fail because all nodes think it will collect enough votes, so after they actually start campaign, no one votes for the other, the campaign has to fail.
judge_split_prevote
solves the problem by adding extra constraint
to split prevote: only vote for nodes that have greater IDs. It's easy
to conclude that it works for peer numbers less than 5. For >=5 nodes,
it's still possible to split again. But it should be enough for most
cases. Because the constraint is only added for split prevote, so even
failure won't lead to worse result.
I have tested it with 10k regions of both configuration capacity 3 and 5, both can finish in two election timeout when one TiKV is down.
To avoid split prevote, maybe we can record the prevote like the read vote (but not need to persist it) and reject incoming vote request in the same term like what real campaign does.
...record the prevote like the read vote...
Recording votes won't solve split vote. If pre-campaign works like actual campaign and split vote can happen in actual campaign, then it can also happen in pre-campaign.
...record the prevote like the read vote...
Recording votes won't solve split vote. If pre-campaign works like actual campaign and split vote can happen in actual campaign, then it can also happen in pre-campaign.
We can't prevent split vote completely, but with random election timeout and vote recording, split vote should happen rarely.
...split vote should happen rarely.
How can recording vote reduce the probability of split vote? It just make the split happen in early stage, from actual vote to pre vote. The strategy here can solve split completely in configuration size 3, and make it hardly happen in configuration size 5.
How can recording vote reduce the probability of split vote?
After recording a prevote at future term, a node should not start pre-compaing or prevote for other nodes (at the same future term) as it already prevote at that future term.
A common situation of split vote in 3 voters situation is that leader is down, and two followers start campaign at the same time. How does the strategy you describe make the campaign succeed in one round of election?
A common situation of split vote in 3 voters situation is that leader is down, and two followers start campaign at the same time. How does the strategy you describe make the campaign succeed in one round of election?
It can't, forget about it, I have some misunderstanding about the problem previously.
PTAL