raft-rs icon indicating copy to clipboard operation
raft-rs copied to clipboard

*: introduce judge_split_prevote

Open BusyJay opened this issue 3 years ago • 9 comments

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.

BusyJay avatar Mar 06 '21 15:03 BusyJay

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.

BusyJay avatar Mar 07 '21 15:03 BusyJay

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.

NingLin-P avatar Mar 08 '21 08:03 NingLin-P

...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.

BusyJay avatar Mar 08 '21 08:03 BusyJay

...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.

NingLin-P avatar Mar 08 '21 08:03 NingLin-P

...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.

BusyJay avatar Mar 08 '21 08:03 BusyJay

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.

NingLin-P avatar Mar 08 '21 08:03 NingLin-P

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?

BusyJay avatar Mar 08 '21 09:03 BusyJay

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.

NingLin-P avatar Mar 08 '21 13:03 NingLin-P

PTAL

BusyJay avatar Jun 25 '21 12:06 BusyJay