diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/Coordinator.java b/server/src/main/java/org/elasticsearch/cluster/coordination/Coordinator.java index f003746331192..2fe4408d142d3 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/Coordinator.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/Coordinator.java @@ -1568,7 +1568,7 @@ public void publish( clusterStatePublicationEvent.getSummary() ) ); - throw new FailedToCommitClusterStateException("publication " + currentPublication.get() + " already in progress"); + throw new NotMasterException("publication " + currentPublication.get() + " already in progress"); } assert assertPreviousStateConsistency(clusterStatePublicationEvent); @@ -1587,7 +1587,7 @@ assert getLocalNode().equals(clusterState.getNodes().get(getLocalNode().getId()) } catch (Exception e) { logger.debug(() -> "[" + clusterStatePublicationEvent.getSummary() + "] publishing failed during context creation", e); becomeCandidate("publication context creation"); - throw new FailedToCommitClusterStateException("publishing failed during context creation", e); + throw new NotMasterException("publishing failed during context creation", e); } try (Releasable ignored = publicationContext::decRef) { @@ -1608,7 +1608,7 @@ assert getLocalNode().equals(clusterState.getNodes().get(getLocalNode().getId()) e ); becomeCandidate("publication creation"); - throw new FailedToCommitClusterStateException("publishing failed while starting", e); + throw new NotMasterException("publishing failed while starting", e); } try { diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/FailedToCommitClusterStateException.java b/server/src/main/java/org/elasticsearch/cluster/coordination/FailedToCommitClusterStateException.java index 4029d82d95d56..1f5433b7d40f5 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/FailedToCommitClusterStateException.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/FailedToCommitClusterStateException.java @@ -16,14 +16,19 @@ import java.io.IOException; /** - * Thrown when a cluster state publication fails to commit the new cluster state. If publication fails then a new master is elected but the - * update might or might not take effect, depending on whether the newly-elected master accepted the published state that failed to - * be committed. This exception should only be used when there is ambiguity whether a state update took effect or not. - * - * This is different from {@link NotMasterException} where we know for certain that a state update never took effect. - * - * This exception is retryable within {@link TransportMasterNodeAction}. - * + * Exception indicating a cluster state update was published but not committed to all nodes. + *
+ * If this exception is thrown, then the cluster state update was published, but is not guaranteed + * to be committed on any nodes, including the next master node. This exception should only be thrown when there is + * ambiguity whether a cluster state update has been committed. + *
+ * For exceptions thrown prior to publication, + * when the cluster update has definitely failed, use a different exception. + *
+ * If during a cluster state update the node is no longer master, use a {@link NotMasterException} + *
+ * This is a retryable exception inside {@link TransportMasterNodeAction} + *
* See {@link ClusterStatePublisher} for more details. */ public class FailedToCommitClusterStateException extends ElasticsearchException {