diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/tasks/PendingTasksBlocksIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/tasks/PendingTasksBlocksIT.java index 2be4acd16671f..45de63f790b12 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/tasks/PendingTasksBlocksIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/tasks/PendingTasksBlocksIT.java @@ -32,6 +32,7 @@ package org.opensearch.action.admin.cluster.tasks; +import org.opensearch.action.admin.cluster.node.info.NodesInfoRequest; import org.opensearch.common.settings.Settings; import org.opensearch.gateway.GatewayService; import org.opensearch.test.InternalTestCluster; @@ -91,11 +92,12 @@ public void testPendingTasksWithClusterNotRecoveredBlock() throws Exception { } // restart the cluster but prevent it from performing state recovery - final int nodeCount = client().admin().cluster().prepareNodesInfo("data:true", "cluster_manager:true").get().getNodes().size(); + NodesInfoRequest nodesInfoRequest = new NodesInfoRequest(); + final int dataNodesCount = client().admin().cluster().prepareNodesInfo("data:true").get().getNodes().size(); internalCluster().fullRestart(new InternalTestCluster.RestartCallback() { @Override public Settings onNodeStopped(String nodeName) { - return Settings.builder().put(GatewayService.RECOVER_AFTER_DATA_NODES_SETTING.getKey(), nodeCount + 1).build(); + return Settings.builder().put(GatewayService.RECOVER_AFTER_DATA_NODES_SETTING.getKey(), dataNodesCount + 1).build(); } @Override diff --git a/server/src/main/java/org/opensearch/action/support/TransportActions.java b/server/src/main/java/org/opensearch/action/support/TransportActions.java index 8c5f67d66410f..4cfe0944004fa 100644 --- a/server/src/main/java/org/opensearch/action/support/TransportActions.java +++ b/server/src/main/java/org/opensearch/action/support/TransportActions.java @@ -67,7 +67,11 @@ public static boolean isReadOverrideException(Exception e) { } public static boolean isRetryableSearchException(final Exception e) { - return (OpenSearchException.status(e).getStatus() / 100 != 4) && (e.getCause() instanceof TaskCancelledException == false); + + return (OpenSearchException.status(e).getStatus() / 100 != 4) && (e.getCause() instanceof TaskCancelledException == false) + // There exists a scenario where a primary shard (0 replicas) relocates and is in POST_RECOVERY on the + // target node but already deleted on the source node. Search request should still work. + || (e.getCause() instanceof IndexNotFoundException); } }