Skip to content

Commit 95a02b8

Browse files
committed
Ignore failures on skip_unavailable
1 parent 70824c4 commit 95a02b8

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package org.elasticsearch.xpack.esql.plugin;
99

1010
import org.elasticsearch.action.ActionListener;
11+
import org.elasticsearch.action.search.ShardSearchFailure;
1112
import org.elasticsearch.action.support.RefCountingListener;
1213
import org.elasticsearch.compute.operator.DriverProfile;
1314
import org.elasticsearch.compute.operator.FailureCollector;
@@ -188,6 +189,27 @@ ActionListener<Void> acquireAvoid() {
188189
});
189190
}
190191

192+
ActionListener<Void> acquireSkipUnavailable(@Nullable String computeClusterAlias) {
193+
if (computeClusterAlias == null
194+
|| esqlExecutionInfo.isCrossClusterSearch() == false
195+
|| runningOnRemoteCluster()
196+
|| computeClusterAlias.equals(RemoteClusterAware.LOCAL_CLUSTER_GROUP_KEY)
197+
|| esqlExecutionInfo.isSkipUnavailable(computeClusterAlias) == false) {
198+
return acquireAvoid();
199+
}
200+
return refs.acquire().delegateResponse((l, e) -> {
201+
LOGGER.error("Skipping unavailable cluster {} in ESQL query: {}", computeClusterAlias, e);
202+
esqlExecutionInfo.swapCluster(computeClusterAlias, (k, v) -> {
203+
assert v.getStatus() != EsqlExecutionInfo.Cluster.Status.SKIPPED
204+
: "We shouldn't be running compute on a cluster that's already marked as skipped";
205+
return new EsqlExecutionInfo.Cluster.Builder(v).setStatus(EsqlExecutionInfo.Cluster.Status.PARTIAL)
206+
.setFailures(List.of(new ShardSearchFailure(e)))
207+
.build();
208+
});
209+
l.onResponse(null);
210+
});
211+
}
212+
191213
/**
192214
* Acquires a new listener that collects compute result. This listener will also collect warnings emitted during compute
193215
* @param computeClusterAlias The cluster alias where the compute is happening. Used when metadata needs to be gathered
@@ -198,7 +220,7 @@ ActionListener<ComputeResponse> acquireCompute(@Nullable String computeClusterAl
198220
assert computeClusterAlias == null || (esqlExecutionInfo != null && esqlExecutionInfo.getRelativeStartNanos() != null)
199221
: "When clusterAlias is provided to acquireCompute, executionInfo and relativeStartTimeNanos must be non-null";
200222

201-
return acquireAvoid().map(resp -> {
223+
return acquireSkipUnavailable(computeClusterAlias).map(resp -> {
202224
responseHeaders.collect();
203225
var profiles = resp.getProfiles();
204226
if (profiles != null && profiles.isEmpty() == false) {

0 commit comments

Comments
 (0)