Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check correct term earlier in publication process #39909

Merged
merged 2 commits into from
Mar 11, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -952,10 +952,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