diff --git a/core/src/main/java/org/elasticsearch/cluster/action/shard/ShardStateAction.java b/core/src/main/java/org/elasticsearch/cluster/action/shard/ShardStateAction.java index 71917e2e8c7..9a0d7e55ac3 100644 --- a/core/src/main/java/org/elasticsearch/cluster/action/shard/ShardStateAction.java +++ b/core/src/main/java/org/elasticsearch/cluster/action/shard/ShardStateAction.java @@ -44,6 +44,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.discovery.Discovery; import org.elasticsearch.node.NodeClosedException; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.EmptyTransportResponseHandler; @@ -121,7 +122,12 @@ public class ShardStateAction extends AbstractComponent { } } - private static Set> MASTER_CHANNEL_EXCEPTIONS = new HashSet<>(Arrays.asList(NotMasterException.class, NodeDisconnectedException.class)); + private static Set> MASTER_CHANNEL_EXCEPTIONS = + new HashSet<>(Arrays.asList( + NotMasterException.class, + NodeDisconnectedException.class, + Discovery.FailedToCommitClusterStateException.class + )); private static boolean isMasterChannelException(Throwable cause) { return MASTER_CHANNEL_EXCEPTIONS.contains(cause.getClass()); } diff --git a/core/src/test/java/org/elasticsearch/cluster/action/shard/ShardStateActionTests.java b/core/src/test/java/org/elasticsearch/cluster/action/shard/ShardStateActionTests.java index 8aca7849343..ba445c939d3 100644 --- a/core/src/test/java/org/elasticsearch/cluster/action/shard/ShardStateActionTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/action/shard/ShardStateActionTests.java @@ -31,6 +31,7 @@ import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.ShardsIterator; import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.discovery.Discovery; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.cluster.TestClusterService; import org.elasticsearch.test.transport.CapturingTransport; @@ -49,6 +50,7 @@ import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; import static org.elasticsearch.action.support.replication.ClusterStateCreationUtils.stateWithStartedPrimary; import static org.hamcrest.CoreMatchers.equalTo; @@ -163,6 +165,7 @@ public class ShardStateActionTests extends ESTestCase { AtomicBoolean noMaster = new AtomicBoolean(); AtomicBoolean retried = new AtomicBoolean(); AtomicBoolean success = new AtomicBoolean(); + AtomicReference exception = new AtomicReference<>(); setUpMasterRetryVerification(noMaster, retried, latch); @@ -176,6 +179,7 @@ public class ShardStateActionTests extends ESTestCase { @Override public void onShardFailedFailure(Exception e) { success.set(false); + exception.set(e); latch.countDown(); } }); @@ -187,9 +191,11 @@ public class ShardStateActionTests extends ESTestCase { List possibleExceptions = new ArrayList<>(); possibleExceptions.add(new NotMasterException("simulated")); possibleExceptions.add(new NodeDisconnectedException(clusterService.state().nodes().masterNode(), ShardStateAction.SHARD_FAILED_ACTION_NAME)); + possibleExceptions.add(new Discovery.FailedToCommitClusterStateException("simulated")); transport.handleResponse(capturedRequests[0].requestId, randomFrom(possibleExceptions)); latch.await(); + assertNull(exception.get()); assertTrue(success.get()); }