4646import java .util .concurrent .Executor ;
4747import java .util .concurrent .Semaphore ;
4848import java .util .concurrent .atomic .AtomicBoolean ;
49+ import java .util .concurrent .atomic .AtomicInteger ;
4950import java .util .concurrent .locks .ReentrantLock ;
5051
5152/**
@@ -62,6 +63,7 @@ abstract class DataNodeRequestSender {
6263 private final Queue <ShardId > pendingShardIds = ConcurrentCollections .newQueue ();
6364 private final Map <DiscoveryNode , Semaphore > nodePermits = new HashMap <>();
6465 private final Map <ShardId , ShardFailure > shardFailures = ConcurrentCollections .newConcurrentMap ();
66+ private final AtomicInteger skippedShards = new AtomicInteger ();
6567 private final AtomicBoolean changed = new AtomicBoolean ();
6668 private boolean reportedFailure = false ; // guarded by sendingLock
6769 private volatile boolean skipRemaining = false ;
@@ -91,12 +93,13 @@ final void startComputeOnDataNodes(
9193 final long startTimeInNanos = System .nanoTime ();
9294 searchShards (rootTask , clusterAlias , requestFilter , concreteIndices , originalIndices , ActionListener .wrap (targetShards -> {
9395 try (var computeListener = new ComputeListener (transportService .getThreadPool (), runOnTaskFailure , listener .map (profiles -> {
96+ var skipped = skippedShards .get () + pendingShardIds .size ();
9497 return new ComputeResponse (
9598 profiles ,
9699 TimeValue .timeValueNanos (System .nanoTime () - startTimeInNanos ),
97100 targetShards .totalShards (),
98- targetShards .totalShards () - shardFailures .size (),
99- targetShards .skippedShards (),
101+ targetShards .totalShards () - shardFailures .size () - skipped ,
102+ targetShards .skippedShards () + skipped ,
100103 shardFailures .size ()
101104 );
102105 }))) {
@@ -202,6 +205,7 @@ public void onFailure(Exception e, boolean receivedData) {
202205
203206 @ Override
204207 public void onSkip (boolean skipRemaining ) {
208+ DataNodeRequestSender .this .skippedShards .incrementAndGet ();
205209 if (skipRemaining ) {
206210 DataNodeRequestSender .this .skipRemaining = true ;
207211 }
0 commit comments