You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by GitBox <gi...@apache.org> on 2022/11/28 23:25:01 UTC

[GitHub] [ratis] szetszwo commented on a diff in pull request #792: RATIS-1754. Set leader to null when stepping down

szetszwo commented on code in PR #792:
URL: https://github.com/apache/ratis/pull/792#discussion_r1034147470


##########
ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java:
##########
@@ -568,6 +568,7 @@ void submitStepDownEvent(long term, StepDownReason reason) {
   private void stepDown(long term, StepDownReason reason) {
     try {
       server.changeToFollowerAndPersistMetadata(term, false, reason);
+      server.getState().setLeader(null, "stepDown");

Review Comment:
   Let's set it in `changeToFollower` as below
   ```java
   +++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
   @@ -534,6 +534,7 @@ class RaftServerImpl implements RaftServer.Division,
          setRole(RaftPeerRole.FOLLOWER, reason);
          if (old == RaftPeerRole.LEADER) {
            role.shutdownLeaderState(false);
   +        state.setLeader(null, reason);
          } else if (old == RaftPeerRole.CANDIDATE) {
            role.shutdownLeaderElection();
          } else if (old == RaftPeerRole.FOLLOWER) {
   ```



-- 
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: issues-unsubscribe@ratis.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org