Skip to content

Commit

Permalink
Log the reason for any Raft leader step down.
Browse files Browse the repository at this point in the history
  • Loading branch information
archiecobbs committed Aug 28, 2018
1 parent 2a74e3b commit 4aa0759
Showing 1 changed file with 7 additions and 6 deletions.
Expand Up @@ -147,9 +147,13 @@ public Timestamp getLeaseTimeout() {
* @throws IllegalStateException if this role is no longer active or election timer is not running
*/
public void stepDown() {
this.doStepDown("stepDown() invoked");
}

private void doStepDown(String reason) {
synchronized (this.raft) {
Preconditions.checkState(this.raft.role == this, "role is no longer active");
this.debug("stepping down as leader due to invocation of stepDown()");
this.info("stepping down as leader: " + reason);
this.raft.changeRole(new FollowerRole(this.raft));
}
}
Expand Down Expand Up @@ -352,11 +356,8 @@ private void updateLeaderCommitIndex() {
this.updateAllSynchronizedFollowersNow();

// If we are no longer a member of the cluster, step down after the most recent config change is committed
if (!this.raft.isClusterMember() && this.raft.commitIndex >= this.findMostRecentConfigChange()) {
if (this.log.isDebugEnabled())
this.log.debug("stepping down as leader of cluster (no longer a member)");
this.stepDown();
}
if (!this.raft.isClusterMember() && this.raft.commitIndex >= this.findMostRecentConfigChange())
this.doStepDown("no longer a member of my own cluster");
}
}

Expand Down

0 comments on commit 4aa0759

Please sign in to comment.