@@ -462,6 +462,7 @@ protected void doRun(Map<SearchShardIterator, Integer> shardIndexMap) {
462462 }
463463 }
464464 }
465+ final AtomicBoolean phaseFailureEncountered = new AtomicBoolean (false );
465466 perNodeQueries .forEach ((routing , request ) -> {
466467 if (request .shards .size () == 1 ) {
467468 executeAsSingleRequest (routing , request .shards .getFirst ());
@@ -483,6 +484,7 @@ protected void doRun(Map<SearchShardIterator, Integer> shardIndexMap) {
483484 }
484485 searchTransportService .transportService ()
485486 .sendChildRequest (connection , NODE_SEARCH_ACTION_NAME , request , task , new TransportResponseHandler <NodeQueryResponse >() {
487+
486488 @ Override
487489 public NodeQueryResponse read (StreamInput in ) throws IOException {
488490 return new NodeQueryResponse (in );
@@ -533,16 +535,21 @@ public void handleException(TransportException e) {
533535 if (results instanceof QueryPhaseResultConsumer queryPhaseResultConsumer ) {
534536 queryPhaseResultConsumer .failure .compareAndSet (null , cause );
535537 }
536- logger .debug ("Raising phase failure for " + cause + " while executing search on node " + routing .nodeId ());
537- onPhaseFailure (getName (), "" , cause );
538+ if (phaseFailureEncountered .compareAndSet (false , true )) {
539+ logger .debug ("Raising phase failure for " + cause + " while executing search on node " + routing .nodeId ());
540+ onPhaseFailure (getName (), "" , cause );
541+ } else {
542+ // we already failed the phase, ignore any additional failures and just log them if debug enabled
543+ logger .debug ("Ignoring additional phase failure for " + cause + " from search on node " + routing .nodeId ());
544+ }
538545 }
539546 }
540547 });
541548 });
542549 }
543550
544551 private void executeWithoutBatching (CanMatchPreFilterSearchPhase .SendingTarget targetNode , NodeQueryRequest request ) {
545- for (ShardToQuery shard : request .shards ) {
552+ for (SearchQueryThenFetchAsyncAction . ShardToQuery shard : request .shards ) {
546553 executeAsSingleRequest (targetNode , shard );
547554 }
548555 }
0 commit comments