kaijchen opened a new pull request, #844: URL: https://github.com/apache/ratis/pull/844
## What changes were proposed in this pull request? Fix "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. Increase term immediately when `LeaderElection(skipPreVote=true)`, and skip `initElection(Phase.ELECTION)` in the first round in `askForVotes()`. ## 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/4344253556 -- 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]
