-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ES|QL: Wrap remote errors with cluster name to provide more context #123156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pawankartik-elastic
merged 33 commits into
elastic:main
from
pawankartik-elastic:pkar/esql-wrap-remote-errors
Apr 2, 2025
Merged
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
b2fc21d
Wrap remote errors with cluster name to provide more context
pawankartik-elastic a049cc9
Update docs/changelog/123156.yaml
pawankartik-elastic e32956a
Merge branch 'main' into pkar/esql-wrap-remote-errors
pawankartik-elastic cd3fefa
Add test and handle missed subset of scenarios where an error can be
pawankartik-elastic 6daa9e1
Remove unused import
pawankartik-elastic bc166cc
Merge branch 'main' into pkar/esql-wrap-remote-errors
pawankartik-elastic db90b71
Introduce `RemoteComputeException` that forwards the cause's status code
pawankartik-elastic 21cfe8a
Adjust test to match the new exception type
pawankartik-elastic a7bf704
Fix license header
pawankartik-elastic e1e9592
Merge branch 'main' into pkar/esql-wrap-remote-errors
pawankartik-elastic 8e9976d
Adjust test to match the new exception type
pawankartik-elastic 6dd8421
Rename test
pawankartik-elastic 8f2a39d
Merge branch 'main' into pkar/esql-wrap-remote-errors
pawankartik-elastic 57a133a
Reword sentence as per review suggestion
pawankartik-elastic eb27643
Merge branch 'main' into pkar/esql-wrap-remote-errors
pawankartik-elastic ea67731
Register exception as serializable
pawankartik-elastic a155983
Import sort
pawankartik-elastic 24b103d
Merge branch 'main' into pkar/esql-wrap-remote-errors
pawankartik-elastic cb130f5
Fix tests
pawankartik-elastic ca40d5c
Merge branch 'main' into pkar/esql-wrap-remote-errors
pawankartik-elastic fafa4ae
Fix license header
pawankartik-elastic 7dd834e
Merge branch 'main' into pkar/esql-wrap-remote-errors
pawankartik-elastic a5d14a4
Merge branch 'main' into pkar/esql-wrap-remote-errors
pawankartik-elastic 99f9b45
Relax assertions for the wrapping
pawankartik-elastic 2ac89c7
Remove redundant getCause()
pawankartik-elastic 32e26f6
Merge branch 'main' into pkar/esql-wrap-remote-errors
pawankartik-elastic 764933f
Merge branch 'main' into pkar/esql-wrap-remote-errors
pawankartik-elastic 8ef049f
Ensure transport errors are unwrapped before sending response to the
pawankartik-elastic 04149a4
Address review comment: rename exception
pawankartik-elastic 4e0baa3
[CI] Auto commit changes from spotless
8a5d6a0
Merge branch 'main' into pkar/esql-wrap-remote-errors
pawankartik-elastic 90b314a
Rename leftover remnants
pawankartik-elastic 0996521
Address review suggestions
pawankartik-elastic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 123156 | ||
summary: Wrap remote errors with cluster name to provide more context | ||
area: Search | ||
type: enhancement | ||
issues: [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
server/src/main/java/org/elasticsearch/cluster/RemoteException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
package org.elasticsearch.cluster; | ||
|
||
import org.elasticsearch.ElasticsearchException; | ||
import org.elasticsearch.ExceptionsHelper; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.rest.RestStatus; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Represents an error that occurred on a remote node. | ||
* It allows capturing some context such as the cluster alias that encountered the error. | ||
*/ | ||
public class RemoteException extends ElasticsearchException { | ||
|
||
/** | ||
* @param clusterAlias Name of the cluster. | ||
* @param cause Error that was encountered. | ||
*/ | ||
public RemoteException(String clusterAlias, Throwable cause) { | ||
super("Remote [" + clusterAlias + "] encountered an error", cause); | ||
Objects.requireNonNull(cause); | ||
} | ||
|
||
public RemoteException(StreamInput in) throws IOException { | ||
super(in); | ||
} | ||
|
||
@Override | ||
public RestStatus status() { | ||
// This is similar to what we do in SearchPhaseExecutionException. | ||
return ExceptionsHelper.status(getCause()); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...c/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlRemoteErrorWrapIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.esql.action; | ||
|
||
import org.elasticsearch.cluster.RemoteException; | ||
import org.elasticsearch.compute.operator.exchange.ExchangeService; | ||
import org.elasticsearch.test.transport.MockTransportService; | ||
import org.elasticsearch.transport.TransportService; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
|
||
public class EsqlRemoteErrorWrapIT extends AbstractCrossClusterTestCase { | ||
|
||
public void testThatRemoteErrorsAreWrapped() throws Exception { | ||
setupClusters(2); | ||
setSkipUnavailable(REMOTE_CLUSTER_1, false); | ||
setSkipUnavailable(REMOTE_CLUSTER_2, false); | ||
|
||
/* | ||
* Let's say something went wrong with the Exchange and its specifics when talking to a remote. | ||
* And let's pretend only cluster-a is affected. | ||
*/ | ||
for (var nodes : cluster(REMOTE_CLUSTER_1).getNodeNames()) { | ||
((MockTransportService) cluster(REMOTE_CLUSTER_1).getInstance(TransportService.class, nodes)).addRequestHandlingBehavior( | ||
ExchangeService.OPEN_EXCHANGE_ACTION_NAME, | ||
(requestHandler, transportRequest, transportChannel, transportTask) -> { | ||
throw new IllegalArgumentException("some error to wreck havoc"); | ||
} | ||
); | ||
} | ||
|
||
RemoteException wrappedError = expectThrows( | ||
RemoteException.class, | ||
() -> runQuery("FROM " + REMOTE_CLUSTER_1 + ":*," + REMOTE_CLUSTER_2 + ":* | LIMIT 100", false) | ||
); | ||
assertThat(wrappedError.getMessage(), is("Remote [cluster-a] encountered an error")); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.