Release search context when scroll keep_alive is too large (#62179)
Previously, we close related search contexts if the keep_alive of a scroll is too large. But we accidentally change this behavior in #62061.
This commit is contained in:
parent
2eb1e8bc84
commit
063a6d047c
|
@ -471,7 +471,14 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv
|
|||
SearchShardTask task,
|
||||
ActionListener<ScrollQuerySearchResult> listener) {
|
||||
final LegacyReaderContext readerContext = (LegacyReaderContext) findReaderContext(request.contextId(), request);
|
||||
final Releasable markAsUsed = readerContext.markAsUsed(getScrollKeepAlive(request.scroll()));
|
||||
final Releasable markAsUsed;
|
||||
try {
|
||||
markAsUsed = readerContext.markAsUsed(getScrollKeepAlive(request.scroll()));
|
||||
} catch (Exception e) {
|
||||
// We need to release the reader context of the scroll when we hit any exception (here the keep_alive can be too large)
|
||||
freeReaderContext(readerContext.id());
|
||||
throw e;
|
||||
}
|
||||
runAsync(getExecutor(readerContext.indexShard()), () -> {
|
||||
final ShardSearchRequest shardSearchRequest = readerContext.getShardSearchRequest(null);
|
||||
try (SearchContext searchContext = createContext(readerContext, shardSearchRequest, task, false);
|
||||
|
@ -536,7 +543,14 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv
|
|||
public void executeFetchPhase(InternalScrollSearchRequest request, SearchShardTask task,
|
||||
ActionListener<ScrollQueryFetchSearchResult> listener) {
|
||||
final LegacyReaderContext readerContext = (LegacyReaderContext) findReaderContext(request.contextId(), request);
|
||||
final Releasable markAsUsed = readerContext.markAsUsed(getScrollKeepAlive(request.scroll()));
|
||||
final Releasable markAsUsed;
|
||||
try {
|
||||
markAsUsed = readerContext.markAsUsed(getScrollKeepAlive(request.scroll()));
|
||||
} catch (Exception e) {
|
||||
// We need to release the reader context of the scroll when we hit any exception (here the keep_alive can be too large)
|
||||
freeReaderContext(readerContext.id());
|
||||
throw e;
|
||||
}
|
||||
runAsync(getExecutor(readerContext.indexShard()), () -> {
|
||||
final ShardSearchRequest shardSearchRequest = readerContext.getShardSearchRequest(null);
|
||||
try (SearchContext searchContext = createContext(readerContext, shardSearchRequest, task, false);
|
||||
|
|
Loading…
Reference in New Issue