kaijchen opened a new pull request, #843:
URL: https://github.com/apache/ratis/pull/843

   ## What changes were proposed in this pull request?
   
   > TransferLeadership can be stopped by appendEntries from old leader, see 
Jira for details
   >
   > 1. Transferee received startLeaderElection 
(RaftServerImpl#startLeaderElection:1700 -> 
RaftServerImpl#changeToCandidate:649 -> RoleInfo#startLeaderElection:121 -> 
start new thread LeaderElection)
   > 2. Transferee received appendEntries (stack trace in the log above), and 
become follower.
   > 3. LeaderElection thread in step 1 is running, found the CandidateState is 
already CLOSED by step 2.
   > 
   > The term of transferee is expected to be increased in step 3 
(LeaderElection#run:238 -> LeaderElection#askForVotes:304 -> 
ServerState#initElection:221 -> currentTerm.incrementAndGet).
   > But in this case, step 2 is executed before step 3 when the term hasn't 
been increased.
   
   Maybe we can introduce a Pre-Candidate state along with the Candidate state.
   And increase the term when a peer becomes Candidate instead of in 
LeaderElection.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/RATIS-1796
   
   ## How was this patch tested?
   
   100x TestElectionCommandIntegrationWithGrpc#testElectionTransferCommand
   Before: https://github.com/kaijchen/ratis/actions/runs/4341726755
   After: https://github.com/kaijchen/ratis/actions/runs/4341982282
   
   100x LeaderElectionTests
   Before: https://github.com/kaijchen/ratis/actions/runs/4341978875
   After: https://github.com/kaijchen/ratis/actions/runs/4342023911
   


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