Skip to content

Commit 1b030e7

Browse files
authored
Add an additional cancellation check to the fetch phase (#62577)
In #62357 we introduced an additional optimization that allows us to skip the most of the fetch phase early if no results are found. This change caused some cancellation test failures that were relying on definitive cancellation during the fetch phase. This commit adds an additional quick cancellation check at the very beginning of the fetch phase to make cancellation process more deterministic. Fixes #62530
1 parent cc070bf commit 1b030e7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

server/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ public void execute(SearchContext context) {
9191
LOGGER.trace("{}", new SearchContextSourcePrinter(context));
9292
}
9393

94+
if (context.isCancelled()) {
95+
throw new TaskCancelledException("cancelled");
96+
}
97+
9498
if (context.docIdsToLoadSize() == 0) {
9599
// no individual hits to process, so we shortcut
96100
context.fetchResult().hits(new SearchHits(new SearchHit[0], context.queryResult().getTotalHits(),

0 commit comments

Comments
 (0)