Skip to content

Commit 508d3eb

Browse files
committed
update isPartial
1 parent 56c16d5 commit 508d3eb

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,6 @@ public TimeValue planningTookTime() {
175175
public void markEndQuery() {
176176
assert relativeStartNanos != null : "Relative start time must be set when markEndQuery is called";
177177
overallTook = new TimeValue(System.nanoTime() - relativeStartNanos, TimeUnit.NANOSECONDS);
178-
if (isPartial == false) {
179-
// TODO: Mark individual clusters as partial if failed shards exist
180-
isPartial = clusterInfo.values()
181-
.stream()
182-
.anyMatch(
183-
c -> c.status == Cluster.Status.PARTIAL
184-
|| c.status == Cluster.Status.SKIPPED
185-
|| c.failedShards != null && c.failedShards > 0
186-
);
187-
}
188178
}
189179

190180
// for testing only - use markEndQuery in production code
@@ -256,7 +246,15 @@ public Map<String, Cluster> getClusters() {
256246
* @return the new Cluster object
257247
*/
258248
public Cluster swapCluster(String clusterAlias, BiFunction<String, Cluster, Cluster> remappingFunction) {
259-
return clusterInfo.compute(clusterAlias, remappingFunction);
249+
return clusterInfo.compute(clusterAlias, (unused, oldCluster) -> {
250+
final Cluster newCluster = remappingFunction.apply(clusterAlias, oldCluster);
251+
if (isPartial == false) {
252+
isPartial = newCluster.getStatus() == Cluster.Status.PARTIAL
253+
|| newCluster.getStatus() == Cluster.Status.SKIPPED
254+
|| (newCluster.failedShards != null && newCluster.failedShards > 0);
255+
}
256+
return newCluster;
257+
});
260258
}
261259

262260
@Override

0 commit comments

Comments
 (0)