Skip to content

Commit

Permalink
Check term earlier in publication process (#39909)
Browse files Browse the repository at this point in the history
in order to avoid tripping assertPreviousStateConsistency.

Closes #39314
  • Loading branch information
ywelsch committed Mar 11, 2019
1 parent 368b548 commit b7be724
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -982,10 +982,11 @@ private ClusterState clusterStateWithNoMasterBlock(ClusterState clusterState) {
public void publish(ClusterChangedEvent clusterChangedEvent, ActionListener<Void> publishListener, AckListener ackListener) {
try {
synchronized (mutex) {
if (mode != Mode.LEADER) {
logger.debug(() -> new ParameterizedMessage("[{}] failed publication as not currently leading",
clusterChangedEvent.source()));
publishListener.onFailure(new FailedToCommitClusterStateException("node stepped down as leader during publication"));
if (mode != Mode.LEADER || getCurrentTerm() != clusterChangedEvent.state().term()) {
logger.debug(() -> new ParameterizedMessage("[{}] failed publication as node is no longer master for term {}",
clusterChangedEvent.source(), clusterChangedEvent.state().term()));
publishListener.onFailure(new FailedToCommitClusterStateException("node is no longer master for term " +
clusterChangedEvent.state().term() + " while handling publication"));
return;
}

Expand Down

0 comments on commit b7be724

Please sign in to comment.