Skip to content

Commit b2fc21d

Browse files
Wrap remote errors with cluster name to provide more context
1 parent 21845ad commit b2fc21d

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

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

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
package org.elasticsearch.xpack.esql.plugin;
99

10+
import org.elasticsearch.ElasticsearchException;
1011
import org.elasticsearch.action.ActionListener;
1112
import org.elasticsearch.action.ActionListenerResponseHandler;
1213
import org.elasticsearch.action.OriginalIndices;
@@ -198,21 +199,25 @@ record RemoteCluster(String clusterAlias, Transport.Connection connection, Strin
198199
public void messageReceived(ClusterComputeRequest request, TransportChannel channel, Task task) {
199200
ChannelActionListener<ComputeResponse> listener = new ChannelActionListener<>(channel);
200201
RemoteClusterPlan remoteClusterPlan = request.remoteClusterPlan();
201-
var plan = remoteClusterPlan.plan();
202-
if (plan instanceof ExchangeSinkExec == false) {
203-
listener.onFailure(new IllegalStateException("expected exchange sink for a remote compute; got " + plan));
204-
return;
202+
try {
203+
var plan = remoteClusterPlan.plan();
204+
if (plan instanceof ExchangeSinkExec == false) {
205+
listener.onFailure(new IllegalStateException("expected exchange sink for a remote compute; got " + plan));
206+
return;
207+
}
208+
runComputeOnRemoteCluster(
209+
request.clusterAlias(),
210+
request.sessionId(),
211+
(CancellableTask) task,
212+
request.configuration(),
213+
(ExchangeSinkExec) plan,
214+
Set.of(remoteClusterPlan.targetIndices()),
215+
remoteClusterPlan.originalIndices(),
216+
listener
217+
);
218+
} catch (Exception e) {
219+
listener.onFailure(new ElasticsearchException(request.clusterAlias() + " encountered an error", e));
205220
}
206-
runComputeOnRemoteCluster(
207-
request.clusterAlias(),
208-
request.sessionId(),
209-
(CancellableTask) task,
210-
request.configuration(),
211-
(ExchangeSinkExec) plan,
212-
Set.of(remoteClusterPlan.targetIndices()),
213-
remoteClusterPlan.originalIndices(),
214-
listener
215-
);
216221
}
217222

218223
/**

0 commit comments

Comments
 (0)