Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/132334.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 132334
summary: Do not look over `TaskCancelledException` when looking at failures while
updating CCS info for clusters
area: CCS
type: bug
issues: []
3 changes: 0 additions & 3 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,6 @@ tests:
issue: https://github.com/elastic/elasticsearch/issues/117591
- class: org.elasticsearch.repositories.s3.RepositoryS3ClientYamlTestSuiteIT
issue: https://github.com/elastic/elasticsearch/issues/117596
- class: org.elasticsearch.search.ccs.CrossClusterIT
method: testCancel
issue: https://github.com/elastic/elasticsearch/issues/108061
- class: org.elasticsearch.xpack.ml.integration.RegressionIT
method: testTwoJobsWithSameRandomizeSeedUseSameTrainingSet
issue: https://github.com/elastic/elasticsearch/issues/117805
Expand Down
10 changes: 10 additions & 0 deletions server/src/main/java/org/elasticsearch/ExceptionsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.elasticsearch.core.Nullable;
import org.elasticsearch.index.Index;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.tasks.TaskCancelledException;
import org.elasticsearch.transport.ConnectTransportException;
import org.elasticsearch.transport.NoSeedNodeLeftException;
import org.elasticsearch.transport.NoSuchRemoteClusterException;
Expand Down Expand Up @@ -514,6 +515,15 @@ public static boolean isRemoteUnavailableException(Exception e) {
return false;
}

/**
* Utility method to check if an Exception is/was caused by TaskCancelledException.
* @param e Exception we're interested in evaluating.
* @return true if the Exception is/was caused by TaskCancelledException, else false.
*/
public static boolean isTaskCancelledException(Exception e) {
return ExceptionsHelper.unwrapCausesAndSuppressed(e, ex -> ex instanceof TaskCancelledException).isPresent();
}

private static class GroupBy {
final String reason;
final String index;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.elasticsearch.search.internal.SearchContext;
import org.elasticsearch.search.internal.ShardSearchContextId;
import org.elasticsearch.search.internal.ShardSearchRequest;
import org.elasticsearch.tasks.TaskCancelledException;
import org.elasticsearch.transport.Transport;

import java.util.ArrayList;
Expand Down Expand Up @@ -518,7 +517,7 @@ void onShardFailure(final int shardIndex, SearchShardTarget shardTarget, Excepti
}
// we don't aggregate shard on failures due to the internal cancellation,
// but do keep the header counts right
if ((requestCancelled.get() && isTaskCancelledException(e)) == false) {
if ((requestCancelled.get() && ExceptionsHelper.isTaskCancelledException(e)) == false) {
AtomicArray<ShardSearchFailure> shardFailures = this.shardFailures.get();
// lazily create shard failures, so we can early build the empty shard failure list in most cases (no failures)
if (shardFailures == null) { // this is double checked locking but it's fine since SetOnce uses a volatile read internally
Expand Down Expand Up @@ -549,10 +548,6 @@ void onShardFailure(final int shardIndex, SearchShardTarget shardTarget, Excepti
results.consumeShardFailure(shardIndex);
}

private static boolean isTaskCancelledException(Exception e) {
return ExceptionsHelper.unwrapCausesAndSuppressed(e, ex -> ex instanceof TaskCancelledException).isPresent();
}

/**
* Executed once for every successful shard level request.
* @param result the result returned form the shard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,7 @@ public final void onFailure(Exception e) {
ShardSearchFailure f = new ShardSearchFailure(e);
logCCSError(f, clusterAlias, skipUnavailable);
SearchResponse.Cluster cluster = clusters.getCluster(clusterAlias);
if (skipUnavailable) {
if (skipUnavailable && ExceptionsHelper.isTaskCancelledException(e) == false) {
if (cluster != null) {
ccsClusterInfoUpdate(f, clusters, clusterAlias, true);
}
Expand All @@ -1716,7 +1716,8 @@ public final void onFailure(Exception e) {
ccsClusterInfoUpdate(f, clusters, clusterAlias, false);
}
Exception exception = e;
if (RemoteClusterAware.LOCAL_CLUSTER_GROUP_KEY.equals(clusterAlias) == false) {
if (RemoteClusterAware.LOCAL_CLUSTER_GROUP_KEY.equals(clusterAlias) == false
&& ExceptionsHelper.isTaskCancelledException(e) == false) {
exception = wrapRemoteClusterFailure(clusterAlias, e);
}
if (exceptions.compareAndSet(null, exception) == false) {
Expand Down