Skip to content

Commit 99cc226

Browse files
committed
Make cancel to fail and other feedback
1 parent d3b27a1 commit 99cc226

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClustersCancellationIT.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public void testTasks() throws Exception {
237237
requestFuture.actionGet(30, TimeUnit.SECONDS).close();
238238
}
239239

240-
// Check that cancelling remote task with skip_unavailable=true produces partial
240+
// Check that cancelling remote task with skip_unavailable=true produces failure
241241
public void testCancelSkipUnavailable() throws Exception {
242242
createRemoteIndex(between(10, 100));
243243
EsqlQueryRequest request = EsqlQueryRequest.syncEsqlQueryRequest();
@@ -276,16 +276,9 @@ public void testCancelSkipUnavailable() throws Exception {
276276
} finally {
277277
SimplePauseFieldPlugin.allowEmitting.countDown();
278278
}
279-
var resp = requestFuture.actionGet();
280-
EsqlExecutionInfo executionInfo = resp.getExecutionInfo();
281279

282-
assertNotNull(executionInfo);
283-
assertThat(executionInfo.isPartial(), equalTo(true));
284-
EsqlExecutionInfo.Cluster cluster = executionInfo.getCluster(REMOTE_CLUSTER);
285-
286-
assertThat(cluster.getStatus(), equalTo(EsqlExecutionInfo.Cluster.Status.PARTIAL));
287-
assertThat(cluster.getFailures().size(), equalTo(1));
288-
assertThat(cluster.getFailures().get(0).getCause(), instanceOf(TaskCancelledException.class));
280+
Exception error = expectThrows(Exception.class, requestFuture::actionGet);
281+
assertThat(error.getMessage(), containsString("remote failed"));
289282
}
290283

291284
// Check that closing remote node with skip_unavailable=true produces partial

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClustersQueryIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,8 +846,8 @@ public void testWarnings() throws Exception {
846846
assertTrue(latch.await(30, TimeUnit.SECONDS));
847847
}
848848

849-
// Non-disconnect remote failures still fail the request
850-
public void testRemoteFailureSkipUnavailable() throws IOException {
849+
// Non-disconnect remote failures still fail the request even if skip_unavailable is true
850+
public void testRemoteFailureSkipUnavailableTrue() throws IOException {
851851
Map<String, Object> testClusterInfo = setupFailClusters();
852852
String localIndex = (String) testClusterInfo.get("local.index");
853853
String remote1Index = (String) testClusterInfo.get("remote.index");

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,14 @@ public static void markClusterWithFinalStateAndNoShards(
360360
});
361361
}
362362

363+
/**
364+
* We will ignore the error if it's remote unavailable and the cluster is marked to skip unavailable.
365+
*/
363366
public static boolean shouldIgnoreRuntimeError(EsqlExecutionInfo executionInfo, String clusterAlias, Exception e) {
364367
if (executionInfo.isSkipUnavailable(clusterAlias) == false) {
365368
return false;
366369
}
367370

368-
return ExceptionsHelper.isRemoteUnavailableException(e)
369-
|| (e instanceof RemoteTransportException && ExceptionsHelper.unwrap(e, TaskCancelledException.class) != null);
371+
return ExceptionsHelper.isRemoteUnavailableException(e);
370372
}
371373
}

0 commit comments

Comments
 (0)