Skip to content

Commit 85262a1

Browse files
committed
Prevent closing wrong search contexts in compute service
1 parent 43841a5 commit 85262a1

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
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: 3 additions & 2 deletions
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(
@@ -342,15 +342,16 @@ private void acquireSearchContexts(
342342
// we need to limit the number of active search contexts here or in SearchService
343343
context = searchService.createSearchContext(shardRequest, SearchService.NO_TIMEOUT);
344344
context.preProcess();
345-
searchContexts.add(context);
346345
} catch (Exception e) {
347346
if (addShardLevelFailure(shard.shardId(), e)) {
348347
IOUtils.close(context);
348+
continue;
349349
} else {
350350
IOUtils.closeWhileHandlingException(context, () -> IOUtils.close(searchContexts));
351351
throw e;
352352
}
353353
}
354+
searchContexts.add(context);
354355
}
355356
return searchContexts;
356357
});

0 commit comments

Comments
 (0)