Skip to content

Commit

Permalink
Set electionWon upon commit (elastic#16)
Browse files Browse the repository at this point in the history
The ConsensusState implementation forgot to adapt electionWon on commit.
  • Loading branch information
ywelsch committed Dec 19, 2017
1 parent bfe47ab commit 9d314c4
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,17 @@ public void handleCommit(ApplyCommit applyCommit) {
persistedState.markLastAcceptedStateAsCommitted();
assert getCommittedState().getSlot() == applyCommit.getSlot();
assert getAcceptedState().isPresent() == false;

publishPermitted = true;
final boolean prevElectionWon = electionWon;
electionWon = isQuorumInCurrentConfiguration(joinVotes);
if (prevElectionWon != electionWon) {
if (electionWon) {
logger.debug("handleCommit: election won through reconfiguration change");
} else {
logger.debug("handleCommit: election lost through reconfiguration change");
}
}
publishVotes = new NodeCollection();
}

Expand Down

0 comments on commit 9d314c4

Please sign in to comment.