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

Questions about the TestSplitVote2AA test #453

Open
liiuzq-xiaobai opened this issue Jul 28, 2023 · 2 comments
Open

Questions about the TestSplitVote2AA test #453

liiuzq-xiaobai opened this issue Jul 28, 2023 · 2 comments

Comments

@liiuzq-xiaobai
Copy link

image
Here is the difference.
image
image

I have a question about the TestSplitVote2AA test case, why is it judged to be a candidate for the Splitvote case? I refer to the relevant details in the raft paper. When a splitvote situation occurs, the two raft nodes will vote for each other, and then convert themselves to Followers, so that the two will always be in the voting process.It's right?Thanks for your answer!

@liiuzq-xiaobai
Copy link
Author

Until a subsequent raft node times out first, for example, in this test case, 2 nodes time out, and then it is elected. Shouldn’t they return to follower after giving each other votes before that?

@Water3000
Copy link

Water3000 commented Aug 31, 2023

@liiuzq-xiaobai
First of all, they don't vote for each other. A candidate only votes for itself according to the paper.
Splitting case happens when no one gets votes from the majority and therefore no one becomes the leader.
When this happens, all of the candidates will not change their state until:

  1. Get any kind of RPC containing a larger term -- become a follower. (basic rules for all servers)
  2. Get APrpc("heartbeat") from another peer(i.e. the new leader in this term) -- become a follower.
  3. Election timeout, start a new election and win the campaign -- become a leader.

In this test case, these two candidates share the same term, so No.0 won't happen. Also, no one wins the election so no one will send out heartbeats, therefore No.1 won't happen. As for No.2, however, it will happen in a few lines below your screenshot.

Actually, I think what you've misunderstood here is how the test cases work. Try to look into the send method a few lines above your screenshot. It shows how your msgs are transferred and processed(basically it's just a single-threaded FIFO). In short, this test case uses MessageType_MsgHup to trigger leader election instead of timeout, suspends at the stage when split-vote just happens, and then triggers a new round of election using MessageType_MsgHup again. There is no tick in here, no real election timeout, everything happens under the control of msg. It's a step-by-step test.

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

2 participants