Skip to content

Commit e230c01

Browse files
authored
Prevent closing wrong search contexts in compute service (#128222)
The search context variable should be inside the loop, not outside; otherwise, it may close the previous search context when the target shard is unavailable, potentially leaving search contexts without references. This bug was introduced in unreleased versions (9.1 and 8.19). I think we need to refactor DataNodeComputeHandler to allow writing unit tests for these cases easier, but testSearchWhileRelocating should cover this issue. Closes #127188
1 parent c8581b0 commit e230c01

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,6 @@ tests:
393393
- class: org.elasticsearch.packaging.test.DockerTests
394394
method: test026InstallBundledRepositoryPluginsViaConfigFile
395395
issue: https://github.com/elastic/elasticsearch/issues/127158
396-
- class: org.elasticsearch.xpack.esql.plugin.DataNodeRequestSenderIT
397-
method: testSearchWhileRelocating
398-
issue: https://github.com/elastic/elasticsearch/issues/127188
399396
- class: org.elasticsearch.xpack.remotecluster.CrossClusterEsqlRCS2EnrichUnavailableRemotesIT
400397
method: testEsqlEnrichWithSkipUnavailable
401398
issue: https://github.com/elastic/elasticsearch/issues/127368

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeComputeHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@ private void acquireSearchContexts(
328328
}
329329
final var doAcquire = ActionRunnable.supply(listener, () -> {
330330
final List<SearchContext> searchContexts = new ArrayList<>(targetShards.size());
331-
SearchContext context = null;
332331
for (IndexShard shard : targetShards) {
332+
SearchContext context = null;
333333
try {
334334
var aliasFilter = aliasFilters.getOrDefault(shard.shardId().getIndex(), AliasFilter.EMPTY);
335335
var shardRequest = new ShardSearchRequest(

0 commit comments

Comments
 (0)