Skip to content

Commit 9d773a3

Browse files
committed
Make skip_unavailable catch all errors
1 parent 12cb957 commit 9d773a3

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,13 @@ void startComputeOnRemoteCluster(
8585
final AtomicReference<ComputeResponse> finalResponse = new AtomicReference<>();
8686
listener = listener.delegateResponse((l, e) -> {
8787
final boolean receivedResults = finalResponse.get() != null || pagesFetched.get();
88-
if (receivedResults == false && EsqlCCSUtils.shouldIgnoreRuntimeError(executionInfo, clusterAlias, e)) {
89-
EsqlCCSUtils.markClusterWithFinalStateAndNoShards(executionInfo, clusterAlias, EsqlExecutionInfo.Cluster.Status.SKIPPED, e);
90-
l.onResponse(DriverCompletionInfo.EMPTY);
91-
} else if (configuration.allowPartialResults() && EsqlCCSUtils.canAllowPartial(e)) {
92-
EsqlCCSUtils.markClusterWithFinalStateAndNoShards(executionInfo, clusterAlias, EsqlExecutionInfo.Cluster.Status.PARTIAL, e);
88+
if (EsqlCCSUtils.shouldIgnoreRuntimeError(executionInfo, clusterAlias, e)) {
89+
EsqlCCSUtils.markClusterWithFinalStateAndNoShards(
90+
executionInfo,
91+
clusterAlias,
92+
receivedResults ? EsqlExecutionInfo.Cluster.Status.PARTIAL : EsqlExecutionInfo.Cluster.Status.SKIPPED,
93+
e
94+
);
9395
l.onResponse(DriverCompletionInfo.EMPTY);
9496
} else {
9597
l.onFailure(e);

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,7 @@ public static void markClusterWithFinalStateAndNoShards(
364364
* We will ignore the error if it's remote unavailable and the cluster is marked to skip unavailable.
365365
*/
366366
public static boolean shouldIgnoreRuntimeError(EsqlExecutionInfo executionInfo, String clusterAlias, Exception e) {
367-
if (executionInfo.isSkipUnavailable(clusterAlias) == false) {
368-
return false;
369-
}
370-
371-
return ExceptionsHelper.isRemoteUnavailableException(e);
367+
return executionInfo.isSkipUnavailable(clusterAlias);
372368
}
373369

374370
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,8 +775,8 @@ public void testShouldIgnoreRuntimeError() {
775775
shouldIgnoreRuntimeError(executionInfo, REMOTE1_ALIAS, new IllegalStateException("Unable to open any connections")),
776776
is(true)
777777
);
778-
assertThat(shouldIgnoreRuntimeError(executionInfo, REMOTE1_ALIAS, new TaskCancelledException("task cancelled")), is(false));
779-
assertThat(shouldIgnoreRuntimeError(executionInfo, REMOTE1_ALIAS, new ElasticsearchException("something is wrong")), is(false));
778+
assertThat(shouldIgnoreRuntimeError(executionInfo, REMOTE1_ALIAS, new TaskCancelledException("task cancelled")), is(true));
779+
assertThat(shouldIgnoreRuntimeError(executionInfo, REMOTE1_ALIAS, new ElasticsearchException("something is wrong")), is(true));
780780
// remote2: skip_unavailable=false, so should not ignore any errors
781781
assertThat(
782782
shouldIgnoreRuntimeError(executionInfo, REMOTE2_ALIAS, new IllegalStateException("Unable to open any connections")),

0 commit comments

Comments
 (0)