Check term earlier in publication process (#39909)
in order to avoid tripping assertPreviousStateConsistency. Closes #39314
This commit is contained in:
parent
368b5482fa
commit
b7be724e50
|
@ -982,10 +982,11 @@ public class Coordinator extends AbstractLifecycleComponent implements Discovery
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue