Skip to content

Commit

Permalink
Fix query timeout handling by checking searchContext.isSearchTimedOut()
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta committed Dec 18, 2024
1 parent b5f651f commit 43e54c0
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,20 @@ protected void search(List<LeafReaderContext> leaves, Weight weight, Collector c
// reader order here.
if (searchContext.shouldUseTimeSeriesDescSortOptimization()) {
for (int i = leaves.size() - 1; i >= 0; i--) {
// If search is already flagged as timed out, do not continue
searchLeaf(leaves.get(i), weight, collector);
// If search is already flagged as timed out, do not continue
if (searchContext.isSearchTimedOut()) {
return;

Check warning on line 289 in server/src/main/java/org/opensearch/search/internal/ContextIndexSearcher.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/search/internal/ContextIndexSearcher.java#L289

Added line #L289 was not covered by tests
}
}
} else {
for (int i = 0; i < leaves.size(); i++) {
searchLeaf(leaves.get(i), weight, collector);
// If search is already flagged as timed out, do not continue
if (searchContext.isSearchTimedOut()) {
return;

Check warning on line 297 in server/src/main/java/org/opensearch/search/internal/ContextIndexSearcher.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/search/internal/ContextIndexSearcher.java#L297

Added line #L297 was not covered by tests
}
}
}
searchContext.bucketCollectorProcessor().processPostCollection(collector);
Expand Down

0 comments on commit 43e54c0

Please sign in to comment.