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
5 changes: 5 additions & 0 deletions docs/changelog/125002.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 125002
summary: Don't generate stacktrace in `TaskCancelledException`
area: Search
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;

public class SearchCancellationIT extends AbstractSearchCancellationTestCase {

Expand Down Expand Up @@ -124,7 +125,9 @@ public void testCancellationDuringTimeSeriesAggregation() throws Exception {
logger.info("All shards failed with", ex);
if (lowLevelCancellation) {
// Ensure that we cancelled in TimeSeriesIndexSearcher and not in reduce phase
assertThat(ExceptionsHelper.stackTrace(ex), containsString("TimeSeriesIndexSearcher"));
assertThat(ExceptionsHelper.stackTrace(ex), not(containsString("not building sub-aggregations due to task cancellation")));
} else {
assertThat(ExceptionsHelper.stackTrace(ex), containsString("not building sub-aggregations due to task cancellation"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public TaskCancelledException(StreamInput in) throws IOException {
super(in);
}

@Override
public Throwable fillInStackTrace() {
return this; // this exception doesn't imply a bug, no need for a stack trace
}

@Override
public RestStatus status() {
// Tasks are typically cancelled at the request of the client, so a 4xx status code is more accurate than the default of 500 (and
Expand Down