From a5d0f53860ff1b2c64aa9fb2f643f3fd243c9ef2 Mon Sep 17 00:00:00 2001 From: Luca Cavanna Date: Wed, 11 Oct 2023 12:02:22 +0200 Subject: [PATCH] Disable parallel collection in top hits aggregator TopHitsAggregator calls TopFieldCollector#populateScores from each slice, which in turn relies on createWeight calls against the searcher. This means that the createWeight call gets parallelized with Lucene 9.9, but it should not as we are already executing multiple slices concurrently. We have protecions in place in Lucene to avoid this problem, but we have to adapt our execution code in ContextIndexSearcher accordingly. The goal is to utilize plain TaskExecutor from Lucene and avoid code duplication. In the meantime, we can disable concurrency for top hits aggregations as it causes actual issues currently in the lucene_snapshot branch. --- .../aggregations/metrics/TopHitsAggregationBuilder.java | 5 +++++ .../search/aggregations/metrics/TopHitsTests.java | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/TopHitsAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/TopHitsAggregationBuilder.java index 4a5df855b5095..23e1e6238a279 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/TopHitsAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/TopHitsAggregationBuilder.java @@ -921,4 +921,9 @@ public String getType() { public TransportVersion getMinimalSupportedVersion() { return TransportVersions.ZERO; } + + @Override + public boolean supportsParallelCollection() { + return false; + } } diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsTests.java index 39f583fd2c56b..b017b983ee084 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsTests.java @@ -183,4 +183,8 @@ protected void assertToXContentAfterSerialization(TopHitsAggregationBuilder orig XContentType.JSON ); } + + public void testSupportsParallelCollection() { + assertFalse(createTestAggregatorBuilder().supportsParallelCollection()); + } }