Skip to content

Commit

Permalink
Start the HeartbeatCollector before recording the local node (elastic#26
Browse files Browse the repository at this point in the history
)

Previously, if the leader is a quorum all by itself then the call to
safeAddHeartbeatResponse(localNode) would immediately renew the leader's lease,
skipping the call to start() and suppressing sending heartbeats to all the
other nodes.  This breaks the assertion that, after stabilisation, all other
connected nodes are followers, because they become candidates if they do not
receive heartbeats.

After this change we call start() first so that heartbeats are always sent.
  • Loading branch information
DaveCTurner authored Jan 11, 2018
1 parent 0965384 commit 4939751
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,10 @@ private void startSeekingVotes() {
private void sendHeartBeat() {
HeartbeatRequest heartbeatRequest =
new HeartbeatRequest(consensusState.firstUncommittedSlot(), consensusState.getCurrentTerm());
currentHeartbeatCollector = Optional.of(new HeartbeatCollector());
safeAddHeartbeatResponse(localNode, currentHeartbeatCollector.get());
if (currentHeartbeatCollector.isPresent()) {
currentHeartbeatCollector.get().start(heartbeatRequest);
}
final HeartbeatCollector heartbeatCollector = new HeartbeatCollector();
currentHeartbeatCollector = Optional.of(heartbeatCollector);
heartbeatCollector.start(heartbeatRequest);
safeAddHeartbeatResponse(localNode, heartbeatCollector);
}

public Vote handleStartVote(DiscoveryNode sourceNode, StartVoteRequest startVoteRequest) {
Expand Down

0 comments on commit 4939751

Please sign in to comment.