diff --git a/server/src/main/java/org/elasticsearch/action/search/AbstractSearchAsyncAction.java b/server/src/main/java/org/elasticsearch/action/search/AbstractSearchAsyncAction.java index ec441cd4e58c4..5a923b17f1330 100644 --- a/server/src/main/java/org/elasticsearch/action/search/AbstractSearchAsyncAction.java +++ b/server/src/main/java/org/elasticsearch/action/search/AbstractSearchAsyncAction.java @@ -689,7 +689,7 @@ private void raisePhaseFailure(SearchPhaseExecutionException exception) { * @see #onShardResult(SearchPhaseResult, SearchShardIterator) */ final void onPhaseDone() { // as a tribute to @kimchy aka. finishHim() - executeNextPhase(this, () -> getNextPhase(results, this)); + executeNextPhase(this, this::getNextPhase); } @Override @@ -746,11 +746,8 @@ protected final ShardSearchRequest buildShardSearchRequest(SearchShardIterator s /** * Returns the next phase based on the results of the initial search phase - * @param results the results of the initial search phase. Each non null element in the result array represent a successfully - * executed shard request - * @param context the search context for the next phase */ - protected abstract SearchPhase getNextPhase(SearchPhaseResults results, SearchPhaseContext context); + protected abstract SearchPhase getNextPhase(); private static final class PendingExecutions { private final Semaphore semaphore; diff --git a/server/src/main/java/org/elasticsearch/action/search/DfsQueryPhase.java b/server/src/main/java/org/elasticsearch/action/search/DfsQueryPhase.java index 0b587e72141ff..36d73c0db166a 100644 --- a/server/src/main/java/org/elasticsearch/action/search/DfsQueryPhase.java +++ b/server/src/main/java/org/elasticsearch/action/search/DfsQueryPhase.java @@ -65,10 +65,6 @@ final class DfsQueryPhase extends SearchPhase { this.nextPhaseFactory = nextPhaseFactory; this.context = context; this.searchTransportService = context.getSearchTransport(); - - // register the release of the query consumer to free up the circuit breaker memory - // at the end of the search - context.addReleasable(queryResult); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/search/SearchDfsQueryThenFetchAsyncAction.java b/server/src/main/java/org/elasticsearch/action/search/SearchDfsQueryThenFetchAsyncAction.java index 26eb266cd457e..69ca1569a7c07 100644 --- a/server/src/main/java/org/elasticsearch/action/search/SearchDfsQueryThenFetchAsyncAction.java +++ b/server/src/main/java/org/elasticsearch/action/search/SearchDfsQueryThenFetchAsyncAction.java @@ -98,7 +98,7 @@ protected void executePhaseOnShard( } @Override - protected SearchPhase getNextPhase(final SearchPhaseResults results, SearchPhaseContext context) { + protected SearchPhase getNextPhase() { final List dfsSearchResults = results.getAtomicArray().asList(); final AggregatedDfs aggregatedDfs = SearchPhaseController.aggregateDfs(dfsSearchResults); final List mergedKnnResults = SearchPhaseController.mergeKnnResults(getRequest(), dfsSearchResults); @@ -107,8 +107,8 @@ protected SearchPhase getNextPhase(final SearchPhaseResults res aggregatedDfs, mergedKnnResults, queryPhaseResultConsumer, - (queryResults) -> SearchQueryThenFetchAsyncAction.nextPhase(client, context, queryResults, aggregatedDfs), - context + (queryResults) -> SearchQueryThenFetchAsyncAction.nextPhase(client, this, queryResults, aggregatedDfs), + this ); } diff --git a/server/src/main/java/org/elasticsearch/action/search/SearchQueryThenFetchAsyncAction.java b/server/src/main/java/org/elasticsearch/action/search/SearchQueryThenFetchAsyncAction.java index 33b2cdf74cd79..e92b5bbf4b5e5 100644 --- a/server/src/main/java/org/elasticsearch/action/search/SearchQueryThenFetchAsyncAction.java +++ b/server/src/main/java/org/elasticsearch/action/search/SearchQueryThenFetchAsyncAction.java @@ -147,7 +147,7 @@ static SearchPhase nextPhase( } @Override - protected SearchPhase getNextPhase(final SearchPhaseResults results, SearchPhaseContext context) { + protected SearchPhase getNextPhase() { return nextPhase(client, this, results, null); } diff --git a/server/src/main/java/org/elasticsearch/action/search/TransportOpenPointInTimeAction.java b/server/src/main/java/org/elasticsearch/action/search/TransportOpenPointInTimeAction.java index c4a078d9d00ad..010f96f212116 100644 --- a/server/src/main/java/org/elasticsearch/action/search/TransportOpenPointInTimeAction.java +++ b/server/src/main/java/org/elasticsearch/action/search/TransportOpenPointInTimeAction.java @@ -277,7 +277,7 @@ protected void executePhaseOnShard( } @Override - protected SearchPhase getNextPhase(SearchPhaseResults results, SearchPhaseContext context) { + protected SearchPhase getNextPhase() { return new SearchPhase(getName()) { private void onExecuteFailure(Exception e) { diff --git a/server/src/test/java/org/elasticsearch/action/search/AbstractSearchAsyncActionTests.java b/server/src/test/java/org/elasticsearch/action/search/AbstractSearchAsyncActionTests.java index d8e3151adb61d..f8ecdbd062054 100644 --- a/server/src/test/java/org/elasticsearch/action/search/AbstractSearchAsyncActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/search/AbstractSearchAsyncActionTests.java @@ -94,7 +94,7 @@ private AbstractSearchAsyncAction createAction( SearchResponse.Clusters.EMPTY ) { @Override - protected SearchPhase getNextPhase(final SearchPhaseResults results, SearchPhaseContext context) { + protected SearchPhase getNextPhase() { return null; } diff --git a/server/src/test/java/org/elasticsearch/action/search/SearchAsyncActionTests.java b/server/src/test/java/org/elasticsearch/action/search/SearchAsyncActionTests.java index a796827baa253..f655136cd4ba4 100644 --- a/server/src/test/java/org/elasticsearch/action/search/SearchAsyncActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/search/SearchAsyncActionTests.java @@ -139,7 +139,7 @@ protected void executePhaseOnShard( } @Override - protected SearchPhase getNextPhase(SearchPhaseResults results, SearchPhaseContext context) { + protected SearchPhase getNextPhase() { return new SearchPhase("test") { @Override public void run() { @@ -255,7 +255,7 @@ protected void executePhaseOnShard( } @Override - protected SearchPhase getNextPhase(SearchPhaseResults results, SearchPhaseContext context) { + protected SearchPhase getNextPhase() { return new SearchPhase("test") { @Override public void run() { @@ -359,7 +359,7 @@ protected void executePhaseOnShard( } @Override - protected SearchPhase getNextPhase(SearchPhaseResults results, SearchPhaseContext context) { + protected SearchPhase getNextPhase() { return new SearchPhase("test") { @Override public void run() { @@ -488,7 +488,7 @@ protected void executePhaseOnShard( } @Override - protected SearchPhase getNextPhase(SearchPhaseResults results, SearchPhaseContext context) { + protected SearchPhase getNextPhase() { return new SearchPhase("test") { @Override public void run() { @@ -600,7 +600,7 @@ protected void executePhaseOnShard( } @Override - protected SearchPhase getNextPhase(SearchPhaseResults results, SearchPhaseContext context) { + protected SearchPhase getNextPhase() { return new SearchPhase("test") { @Override public void run() { @@ -680,7 +680,7 @@ protected void executePhaseOnShard( } @Override - protected SearchPhase getNextPhase(SearchPhaseResults results, SearchPhaseContext context) { + protected SearchPhase getNextPhase() { return new SearchPhase("test") { @Override public void run() { diff --git a/server/src/test/java/org/elasticsearch/action/search/SearchQueryThenFetchAsyncActionTests.java b/server/src/test/java/org/elasticsearch/action/search/SearchQueryThenFetchAsyncActionTests.java index e4284937474c7..6357155793fdf 100644 --- a/server/src/test/java/org/elasticsearch/action/search/SearchQueryThenFetchAsyncActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/search/SearchQueryThenFetchAsyncActionTests.java @@ -204,7 +204,7 @@ public void sendExecuteQuery( null ) { @Override - protected SearchPhase getNextPhase(SearchPhaseResults results, SearchPhaseContext context) { + protected SearchPhase getNextPhase() { return new SearchPhase("test") { @Override public void run() {