Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,6 @@ tests:
- class: org.elasticsearch.packaging.test.DockerTests
method: test026InstallBundledRepositoryPluginsViaConfigFile
issue: https://github.com/elastic/elasticsearch/issues/127158
- class: org.elasticsearch.xpack.esql.plugin.DataNodeRequestSenderIT
method: testSearchWhileRelocating
issue: https://github.com/elastic/elasticsearch/issues/127188
- class: org.elasticsearch.xpack.remotecluster.CrossClusterEsqlRCS2EnrichUnavailableRemotesIT
method: testEsqlEnrichWithSkipUnavailable
issue: https://github.com/elastic/elasticsearch/issues/127368
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ private void acquireSearchContexts(
}
final var doAcquire = ActionRunnable.supply(listener, () -> {
final List<SearchContext> searchContexts = new ArrayList<>(targetShards.size());
SearchContext context = null;
for (IndexShard shard : targetShards) {
SearchContext context = null;
try {
var aliasFilter = aliasFilters.getOrDefault(shard.shardId().getIndex(), AliasFilter.EMPTY);
var shardRequest = new ShardSearchRequest(
Expand All @@ -342,15 +342,16 @@ private void acquireSearchContexts(
// we need to limit the number of active search contexts here or in SearchService
context = searchService.createSearchContext(shardRequest, SearchService.NO_TIMEOUT);
context.preProcess();
searchContexts.add(context);
} catch (Exception e) {
if (addShardLevelFailure(shard.shardId(), e)) {
IOUtils.close(context);
continue;
} else {
IOUtils.closeWhileHandlingException(context, () -> IOUtils.close(searchContexts));
throw e;
}
}
searchContexts.add(context);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: I believe it is a bit more readable if context is added in the end of the try block as this emphasizes it is only added when operation is completely successful. Otherwise it looks like a null could be added to a collection sometimes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I've updated this in 6a89947

}
return searchContexts;
});
Expand Down