diff --git a/server/src/main/java/org/elasticsearch/action/support/replication/ReplicationOperation.java b/server/src/main/java/org/elasticsearch/action/support/replication/ReplicationOperation.java index d5fe63149db58..94de57b5f2d94 100644 --- a/server/src/main/java/org/elasticsearch/action/support/replication/ReplicationOperation.java +++ b/server/src/main/java/org/elasticsearch/action/support/replication/ReplicationOperation.java @@ -201,7 +201,9 @@ public void onFailure(Exception replicaException) { private void onNoLongerPrimary(Exception failure) { final Throwable cause = ExceptionsHelper.unwrapCause(failure); final boolean nodeIsClosing = cause instanceof NodeClosedException - || (cause instanceof TransportException && "TransportService is closed stopped can't send request".equals(cause.getMessage())); + || (cause instanceof TransportException && + ("TransportService is closed stopped can't send request".equals(cause.getMessage()) + || "transport stopped, action: internal:cluster/shard/failure".equals(cause.getMessage()))); final String message; if (nodeIsClosing) { message = String.format(Locale.ROOT, diff --git a/server/src/test/java/org/elasticsearch/action/support/replication/ReplicationOperationTests.java b/server/src/test/java/org/elasticsearch/action/support/replication/ReplicationOperationTests.java index 8adb9c2f26b1a..02988e7981a29 100644 --- a/server/src/test/java/org/elasticsearch/action/support/replication/ReplicationOperationTests.java +++ b/server/src/test/java/org/elasticsearch/action/support/replication/ReplicationOperationTests.java @@ -205,8 +205,11 @@ public void testNoLongerPrimary() throws Exception { shardActionFailure = new NodeClosedException(new DiscoveryNode("foo", buildNewFakeTransportAddress(), Version.CURRENT)); } else if (randomBoolean()) { shardActionFailure = new SendRequestTransportException( - new DiscoveryNode("foo", buildNewFakeTransportAddress(), Version.CURRENT), "internal:cluster/shard/failure", + new DiscoveryNode("foo", buildNewFakeTransportAddress(), Version.CURRENT), ShardStateAction.SHARD_FAILED_ACTION_NAME, new TransportException("TransportService is closed stopped can't send request")); + } else if (randomBoolean()) { + shardActionFailure = new TransportException( + "transport stopped, action: " + ShardStateAction.SHARD_FAILED_ACTION_NAME); } else { shardActionFailure = new ShardStateAction.NoLongerPrimaryShardException(failedReplica.shardId(), "the king is dead"); }