Skip to content

Commit

Permalink
Election scheduler should be cancelled after cluster state publication
Browse files Browse the repository at this point in the history
Signed-off-by: Sooraj Sinha <[email protected]>
  • Loading branch information
soosinha committed Jan 2, 2024
1 parent 5ccd134 commit 61a266a
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -472,11 +472,18 @@ private static Optional<Join> joinWithDestination(Optional<Join> lastJoin, Disco
}

private void closePrevotingAndElectionScheduler() {
closePrevoting();
closeElectionScheduler();
}

private void closePrevoting() {
if (prevotingRound != null) {
prevotingRound.close();
prevotingRound = null;
}
}

private void closeElectionScheduler() {
if (electionScheduler != null) {
electionScheduler.close();
electionScheduler = null;
Expand Down Expand Up @@ -724,7 +731,7 @@ void becomeLeader(String method) {
lastKnownLeader = Optional.of(getLocalNode());
peerFinder.deactivate(getLocalNode());
clusterFormationFailureHelper.stop();
closePrevotingAndElectionScheduler();
closePrevoting();
preVoteCollector.update(getPreVoteResponse(), getLocalNode());

assert leaderChecker.leader() == null : leaderChecker.leader();
Expand Down Expand Up @@ -1447,13 +1454,12 @@ protected void onFoundPeersUpdated() {
foundPeers.forEach(expectedVotes::addVote);
expectedVotes.addVote(Coordinator.this.getLocalNode());
final boolean foundQuorum = coordinationState.get().isElectionQuorum(expectedVotes);

if (foundQuorum) {
if (electionScheduler == null) {
startElectionScheduler();
}
} else {
closePrevotingAndElectionScheduler();
closePrevoting();
}
}
}
Expand Down Expand Up @@ -1735,6 +1741,7 @@ public void onSuccess(String source) {
logIncompleteNodes(Level.WARN);
}
cancelTimeoutHandlers();
closeElectionScheduler();
ackListener.onNodeAck(getLocalNode(), null);
publishListener.onResponse(null);
}
Expand Down

0 comments on commit 61a266a

Please sign in to comment.