@@ -377,36 +377,20 @@ private void onShardFailure(final int shardIndex, @Nullable ShardRouting shard,
377
377
onShardFailure (shardIndex , shardTarget , e );
378
378
final ShardRouting nextShard = shardIt .nextOrNull ();
379
379
final boolean lastShard = nextShard == null ;
380
+ logger .debug (() -> new ParameterizedMessage ("{}: Failed to execute [{}] lastShard [{}]" ,
381
+ shard != null ? shard .shortSummary () : shardIt .shardId (), request , lastShard ), e );
380
382
if (lastShard ) {
381
383
onShardGroupFailure (shardIndex , shardTarget , e );
382
384
}
383
-
384
- if (totalOps .incrementAndGet () == expectedTotalOps ) {
385
- if (logger .isDebugEnabled ()) {
386
- if (e != null && !TransportActions .isShardNotAvailableException (e )) {
387
- logger .debug (new ParameterizedMessage (
388
- "{}: Failed to execute [{}]" , shard != null ? shard .shortSummary () : shardIt .shardId (), request ), e );
389
- } else if (logger .isTraceEnabled ()) {
390
- logger .trace (new ParameterizedMessage ("{}: Failed to execute [{}]" , shard , request ), e );
391
- }
392
- }
385
+ final int totalOps = this .totalOps .incrementAndGet ();
386
+ if (totalOps == expectedTotalOps ) {
393
387
onPhaseDone ();
388
+ } else if (totalOps > expectedTotalOps ) {
389
+ throw new AssertionError ("unexpected higher total ops [" + totalOps + "] compared to expected [" + expectedTotalOps + "]" ,
390
+ new SearchPhaseExecutionException (getName (), "Shard failures" , null , buildShardFailures ()));
394
391
} else {
395
- // trace log this exception
396
- logger .trace (() -> new ParameterizedMessage (
397
- "{}: Failed to execute [{}] lastShard [{}]" ,
398
- shard != null ? shard .shortSummary () : shardIt .shardId (), request , lastShard ), e );
399
392
if (lastShard == false ) {
400
393
performPhaseOnShard (shardIndex , shardIt , nextShard );
401
- } else {
402
- // no more shards active, add a failure
403
- if (logger .isDebugEnabled () && !logger .isTraceEnabled ()) { // do not double log this exception
404
- if (e != null && !TransportActions .isShardNotAvailableException (e )) {
405
- logger .debug (new ParameterizedMessage (
406
- "{}: Failed to execute [{}] lastShard [{}]" ,
407
- shard != null ? shard .shortSummary () : shardIt .shardId (), request , lastShard ), e );
408
- }
409
- }
410
394
}
411
395
}
412
396
}
@@ -505,8 +489,8 @@ private void successfulShardExecution(SearchShardIterator shardsIt) {
505
489
if (xTotalOps == expectedTotalOps ) {
506
490
onPhaseDone ();
507
491
} else if (xTotalOps > expectedTotalOps ) {
508
- throw new AssertionError ("unexpected higher total ops [" + xTotalOps + "] compared to expected ["
509
- + expectedTotalOps + "]" );
492
+ throw new AssertionError ("unexpected higher total ops [" + xTotalOps + "] compared to expected [" + expectedTotalOps + "]" ,
493
+ new SearchPhaseExecutionException ( getName (), "Shard failures" , null , buildShardFailures ()) );
510
494
}
511
495
}
512
496
0 commit comments