Skip to content

Commit e190ba3

Browse files
romseygeekgmjehovich
authored andcommitted
Avoid holding references to SearchExecutionContext in SourceConfirmedTextQuery (elastic#134887)
Lucene Query objects can hang around for longer than a single search, for example as the key in a Query cache. This means that they should not hold references to anything that is only expected to exist for the duration of a single search request. SourceConfirmedTextQuery holds a lambda to load data during query execution. This commit changes one of the constructor calls to avoid capturing unnecessary references to the SearchExecutionContext, an object which is expected to be short-lived.
1 parent c72c6f5 commit e190ba3

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

docs/changelog/134887.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 134887
2+
summary: Avoid holding references to `SearchExecutionContext` in `SourceConfirmedTextQuery`
3+
area: Mapping
4+
type: bug
5+
issues: []

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/extras/MatchOnlyTextFieldMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,9 @@ private IOFunction<LeafReaderContext, CheckedIntFunction<List<Object>, IOExcepti
301301
String name = storedFieldNameForSyntheticSource();
302302
return storedFieldFetcher(name);
303303
}
304+
ValueFetcher valueFetcher = valueFetcher(searchExecutionContext, null);
305+
SourceProvider sourceProvider = searchExecutionContext.lookup();
304306
return context -> {
305-
ValueFetcher valueFetcher = valueFetcher(searchExecutionContext, null);
306-
SourceProvider sourceProvider = searchExecutionContext.lookup();
307307
valueFetcher.setNextReader(context);
308308
return docID -> {
309309
try {

0 commit comments

Comments
 (0)