Skip to content

Commit 43e54c0

Browse files
committed
Fix query timeout handling by checking searchContext.isSearchTimedOut()
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
1 parent b5f651f commit 43e54c0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,20 @@ protected void search(List<LeafReaderContext> leaves, Weight weight, Collector c
282282
// reader order here.
283283
if (searchContext.shouldUseTimeSeriesDescSortOptimization()) {
284284
for (int i = leaves.size() - 1; i >= 0; i--) {
285+
// If search is already flagged as timed out, do not continue
285286
searchLeaf(leaves.get(i), weight, collector);
287+
// If search is already flagged as timed out, do not continue
288+
if (searchContext.isSearchTimedOut()) {
289+
return;
290+
}
286291
}
287292
} else {
288293
for (int i = 0; i < leaves.size(); i++) {
289294
searchLeaf(leaves.get(i), weight, collector);
295+
// If search is already flagged as timed out, do not continue
296+
if (searchContext.isSearchTimedOut()) {
297+
return;
298+
}
290299
}
291300
}
292301
searchContext.bucketCollectorProcessor().processPostCollection(collector);

0 commit comments

Comments
 (0)