mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-28 01:22:26 -04:00
Don't generate stacktrace in TaskCancelledException (#125002)
This commit is contained in:
parent
0bacede6cc
commit
aba54e8af8
3 changed files with 14 additions and 3 deletions
5
docs/changelog/125002.yaml
Normal file
5
docs/changelog/125002.yaml
Normal file
|
@ -0,0 +1,5 @@
|
|||
pr: 125002
|
||||
summary: Don't generate stacktrace in `TaskCancelledException`
|
||||
area: Search
|
||||
type: bug
|
||||
issues: []
|
|
@ -43,6 +43,7 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcke
|
|||
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 {
|
||||
|
||||
|
@ -97,9 +98,7 @@ public class SearchCancellationIT extends AbstractSearchCancellationTestCase {
|
|||
}
|
||||
|
||||
logger.info("Executing search");
|
||||
// we have to explicitly set error_trace=true for the later exception check for `TimeSeriesIndexSearcher`
|
||||
Client client = client();
|
||||
client.threadPool().getThreadContext().putHeader("error_trace", "true");
|
||||
TimeSeriesAggregationBuilder timeSeriesAggregationBuilder = new TimeSeriesAggregationBuilder("test_agg");
|
||||
ActionFuture<SearchResponse> searchResponse = client.prepareSearch("test")
|
||||
.setQuery(matchAllQuery())
|
||||
|
@ -129,7 +128,9 @@ public class SearchCancellationIT extends AbstractSearchCancellationTestCase {
|
|||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,11 @@ public class TaskCancelledException extends ElasticsearchException {
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue