Skip to content

Commit

Permalink
Add an additional cancellation check to the fetch phase (#62577)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
imotov authored Sep 17, 2020
1 parent cc070bf commit 1b030e7
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ public void execute(SearchContext context) {
LOGGER.trace("{}", new SearchContextSourcePrinter(context));
}

if (context.isCancelled()) {
throw new TaskCancelledException("cancelled");
}

if (context.docIdsToLoadSize() == 0) {
// no individual hits to process, so we shortcut
context.fetchResult().hits(new SearchHits(new SearchHit[0], context.queryResult().getTotalHits(),
Expand Down

0 comments on commit 1b030e7

Please sign in to comment.