Skip to content

Commit c2546a0

Browse files
committed
Fix counting skipped shards with filters
1 parent 5a38160 commit c2546a0

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,6 @@ tests:
309309
- class: org.elasticsearch.xpack.search.CrossClusterAsyncSearchIT
310310
method: testCCSClusterDetailsWhereAllShardsSkippedInCanMatch
311311
issue: https://github.com/elastic/elasticsearch/issues/128418
312-
- class: org.elasticsearch.xpack.esql.action.CrossClusterQueryWithFiltersIT
313-
method: testTimestampFilterFromQuery
314-
issue: https://github.com/elastic/elasticsearch/issues/127332
315312
- class: org.elasticsearch.xpack.esql.plugin.DataNodeRequestSenderIT
316313
method: testSearchWhileRelocating
317314
issue: https://github.com/elastic/elasticsearch/issues/128500

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClusterQueryWithFiltersIT.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ protected void assertClusterMetadata(EsqlExecutionInfo.Cluster clusterMetatata,
6262
protected void assertClusterMetadataSuccess(EsqlExecutionInfo.Cluster clusterMetatata, int shards, long took, String indexExpression) {
6363
assertClusterMetadata(clusterMetatata, took, indexExpression, Status.SUCCESSFUL);
6464
assertThat(clusterMetatata.getTotalShards(), equalTo(shards));
65-
assertThat(clusterMetatata.getSuccessfulShards(), equalTo(shards));
66-
assertThat(clusterMetatata.getSkippedShards(), equalTo(0));
65+
// We should have at least one successful shard for data
66+
assertThat(clusterMetatata.getSuccessfulShards(), greaterThanOrEqualTo(1));
67+
// Some shards may be skipped, but total sum of the shards should match up
68+
assertThat(clusterMetatata.getSkippedShards() + clusterMetatata.getSuccessfulShards(), equalTo(shards));
6769
}
6870

6971
protected void assertClusterMetadataNoShards(EsqlExecutionInfo.Cluster clusterMetatata, long took, String indexExpression) {
@@ -81,7 +83,7 @@ protected void assertClusterMetadataSkippedShards(
8183
) {
8284
assertClusterMetadata(clusterMetatata, took, indexExpression, Status.SUCCESSFUL);
8385
assertThat(clusterMetatata.getTotalShards(), equalTo(shards));
84-
assertThat(clusterMetatata.getSuccessfulShards(), equalTo(shards));
86+
assertThat(clusterMetatata.getSuccessfulShards(), equalTo(0));
8587
assertThat(clusterMetatata.getSkippedShards(), equalTo(shards));
8688
}
8789

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequestSender.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,20 @@ final void startComputeOnDataNodes(Set<String> concreteIndices, Runnable runOnTa
134134
var computeListener = new ComputeListener(
135135
transportService.getThreadPool(),
136136
runOnTaskFailure,
137-
listener.map(
138-
completionInfo -> new ComputeResponse(
137+
listener.map(completionInfo -> {
138+
final int totalSkipShards = targetShards.skippedShards() + skippedShards.get();
139+
final int failedShards = shardFailures.size();
140+
final int successfulShards = targetShards.totalShards() - totalSkipShards - failedShards;
141+
return new ComputeResponse(
139142
completionInfo,
140143
timeValueNanos(System.nanoTime() - startTimeInNanos),
141144
targetShards.totalShards(),
142-
targetShards.totalShards() - shardFailures.size() - skippedShards.get(),
143-
targetShards.skippedShards() + skippedShards.get(),
144-
shardFailures.size(),
145+
successfulShards,
146+
totalSkipShards,
147+
failedShards,
145148
selectFailures()
146-
)
147-
)
149+
);
150+
})
148151
)
149152
) {
150153
pendingShardIds.addAll(order(targetShards));

0 commit comments

Comments
 (0)