kaijchen edited a comment on pull request #500:
URL: https://github.com/apache/ratis/pull/500#issuecomment-922227394


   For a detailed example, in 3-node Raft group.
   
   | Node | Role | Term | Log Index -> | 1 | 2 | 3 | 4 | 5 | 6 |
   | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
   | A | Leader | 1 | Log Term -> | 1 | 1 | 1 | 1 | 1 | |
   | B | Candidate | 2 | Log Term -> | 1 | 1 | 1 | | | |
   | C | Follower | 1 | Log Term -> | 1 | 1 | | | | |
   
   1. It is possible for B to passed the PreVote stage and became a candidate, 
`B {term = 2, voteFor = B}`
       * The message is `RequestForVote {candidate = B, term = 2, lastLogTerm = 
1, lastLogIndex = 3}`.
   2. B -> A: RequestForVote
       * **A rejects the vote request and steps down**, `A {term = 2, voteFor = 
None}`.
   3. B -> C: RequestForVote
       * C accepts the vote request, `C {term = 2, voteFor = B}`.
   4. B got quorum votes and became the new leader.
   5. B begin to send AppendEntries requests to A and C.
   
   The end result might look like this.
   
   | Node | Role | Term | Log Index -> | 1 | 2 | 3 | 4 | 5 | 6 |
   | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
   | A | Follower | 2 | Log Term -> | 1 | 1 | 1 | 2 | | |
   | B | Leader | 2 | Log Term -> | 1 | 1 | 1 | 2 | 2 | 2 |
   | C | Follower | 2 | Log Term -> | 1 | 1 | 1 | 2 | 2 | |
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to