Skip to content

Commit 49ed90e

Browse files
committed
Better exception check
1 parent a8662d8 commit 49ed90e

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.util.concurrent.atomic.AtomicReference;
4040

4141
import static org.elasticsearch.xpack.esql.session.EsqlSessionCCSUtils.markClusterWithFinalStateAndNoShards;
42+
import static org.elasticsearch.xpack.esql.session.EsqlSessionCCSUtils.shouldIgnoreRuntimeError;
4243

4344
/**
4445
* Manages computes across multiple clusters by sending {@link ClusterComputeRequest} to remote clusters and executing the computes.
@@ -131,7 +132,7 @@ void startComputeOnRemoteCluster(
131132
new ActionListenerResponseHandler<>(clusterListener, ComputeResponse::new, esqlExecutor)
132133
);
133134
}, e -> {
134-
if (executionInfo.isSkipUnavailable(clusterAlias)) {
135+
if (shouldIgnoreRuntimeError(executionInfo, clusterAlias, e)) {
135136
markClusterWithFinalStateAndNoShards(executionInfo, clusterAlias, EsqlExecutionInfo.Cluster.Status.SKIPPED, e);
136137
openExchangeListener.onResponse(null);
137138
} else {

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262

6363
import static org.elasticsearch.xpack.esql.plugin.EsqlPlugin.ESQL_WORKER_THREAD_POOL_NAME;
6464
import static org.elasticsearch.xpack.esql.session.EsqlSessionCCSUtils.markClusterWithFinalStateAndNoShards;
65+
import static org.elasticsearch.xpack.esql.session.EsqlSessionCCSUtils.shouldIgnoreRuntimeError;
6566

6667
/**
6768
* Computes the result of a {@link PhysicalPlan}.
@@ -284,7 +285,7 @@ public void execute(
284285
updateExecutionInfo(execInfo, clusterAlias, r);
285286
remoteListener.onResponse(r.getProfiles());
286287
}, e -> {
287-
if (shouldIgnoreRemoteError(clusterAlias, e)) {
288+
if (shouldIgnoreRuntimeError(execInfo, clusterAlias, e)) {
288289
markClusterWithFinalStateAndNoShards(execInfo, clusterAlias, EsqlExecutionInfo.Cluster.Status.SKIPPED, e);
289290
remoteListener.onResponse(Collections.emptyList());
290291
} else {
@@ -297,10 +298,6 @@ public void execute(
297298
}
298299
}
299300

300-
private boolean shouldIgnoreRemoteError(String clusterAlias, Exception e) {
301-
return true;
302-
}
303-
304301
private void updateExecutionInfo(EsqlExecutionInfo executionInfo, String clusterAlias, ComputeResponse resp) {
305302
Function<EsqlExecutionInfo.Cluster.Status, EsqlExecutionInfo.Cluster.Status> runningToSuccess = status -> {
306303
if (status == EsqlExecutionInfo.Cluster.Status.RUNNING) {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,4 +357,11 @@ public static void markClusterWithFinalStateAndNoShards(
357357
return builder.build();
358358
});
359359
}
360+
361+
public static boolean shouldIgnoreRuntimeError(EsqlExecutionInfo executionInfo, String clusterAlias, Exception e) {
362+
if (executionInfo.isSkipUnavailable(clusterAlias) == false) {
363+
return false;
364+
}
365+
return ExceptionsHelper.isRemoteUnavailableException(e);
366+
}
360367
}

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/session/EsqlSessionCCSUtilsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ public void testUpdateExecutionInfoAtEndOfPlanning() {
534534

535535
private void assertClusterStatusAndShardCounts(EsqlExecutionInfo.Cluster cluster, EsqlExecutionInfo.Cluster.Status status) {
536536
assertThat(cluster.getStatus(), equalTo(status));
537-
assertNull(cluster.getTook());
537+
assertThat(cluster.getTook().millis(), greaterThanOrEqualTo(0L));
538538
if (status == EsqlExecutionInfo.Cluster.Status.RUNNING) {
539539
assertNull(cluster.getTotalShards());
540540
assertNull(cluster.getSuccessfulShards());

0 commit comments

Comments
 (0)