Skip to content

Commit

Permalink
Don't hold onto ClusterState reference in AbstractSearchAsyncAction
Browse files Browse the repository at this point in the history
  • Loading branch information
romseygeek committed Oct 16, 2023
1 parent 76b9d95 commit 8d1e8fe
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ abstract class AbstractSearchAsyncAction<Result extends SearchPhaseResult> exten
private final BiFunction<String, String, Transport.Connection> nodeIdToConnection;
private final SearchTask task;
protected final SearchPhaseResults<Result> results;
private final ClusterState clusterState;
private final long clusterStateVersion;
private final TransportVersion minTransportVersion;
private final Map<String, AliasFilter> aliasFilter;
private final Map<String, Float> concreteIndexBoosts;
private final SetOnce<AtomicArray<ShardSearchFailure>> shardFailures = new SetOnce<>();
Expand Down Expand Up @@ -161,8 +162,9 @@ abstract class AbstractSearchAsyncAction<Result extends SearchPhaseResult> exten
this.task = task;
this.listener = ActionListener.runAfter(listener, this::releaseContext);
this.nodeIdToConnection = nodeIdToConnection;
this.clusterState = clusterState;
this.concreteIndexBoosts = concreteIndexBoosts;
this.clusterStateVersion = clusterState.version();
this.minTransportVersion = clusterState.getMinTransportVersion();
this.aliasFilter = aliasFilter;
this.results = resultConsumer;
this.clusters = clusters;
Expand Down Expand Up @@ -459,7 +461,7 @@ public final void executeNextPhase(SearchPhase currentPhase, SearchPhase nextPha
currentPhase.getName(),
nextPhase.getName(),
resultsFrom,
clusterState.version()
clusterStateVersion
);
}
executePhase(nextPhase);
Expand Down Expand Up @@ -709,7 +711,6 @@ public void sendSearchResponse(InternalSearchResponse internalSearchResponse, At
if (allowPartialResults == false && failures.length > 0) {
raisePhaseFailure(new SearchPhaseExecutionException("", "Shard failures", null, failures));
} else {
final TransportVersion minTransportVersion = clusterState.getMinTransportVersion();
final String scrollId = request.scroll() != null ? TransportSearchHelper.buildScrollId(queryResults) : null;
final String searchContextId;
if (buildPointInTimeFromSearchResults()) {
Expand Down

0 comments on commit 8d1e8fe

Please sign in to comment.