Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -400,9 +400,6 @@ tests:
- class: org.elasticsearch.xpack.restart.FullClusterRestartIT
method: testWatcherWithApiKey {cluster=UPGRADED}
issue: https://github.com/elastic/elasticsearch/issues/119396
- class: org.elasticsearch.upgrades.SearchStatesIT
method: testCanMatch
issue: https://github.com/elastic/elasticsearch/issues/118718
- class: org.elasticsearch.search.profile.dfs.DfsProfilerIT
method: testProfileDfs
issue: https://github.com/elastic/elasticsearch/issues/119711
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionListenerResponseHandler;
import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.OriginalIndices;
import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest;
import org.elasticsearch.action.admin.cluster.node.tasks.get.TransportGetTaskAction;
import org.elasticsearch.action.support.ChannelActionListener;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.internal.OriginSettingClient;
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.cluster.node.DiscoveryNode;
Expand Down Expand Up @@ -350,6 +352,38 @@ private static class ClearScrollContextsRequest extends TransportRequest {
}
}

static class SearchFreeContextRequest extends ScrollFreeContextRequest implements IndicesRequest {
private final OriginalIndices originalIndices;

SearchFreeContextRequest(StreamInput in) throws IOException {
super(in);
originalIndices = OriginalIndices.readOriginalIndices(in);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
OriginalIndices.writeOriginalIndices(originalIndices, out);
}

@Override
public String[] indices() {
if (originalIndices == null) {
return null;
}
return originalIndices.indices();
}

@Override
public IndicesOptions indicesOptions() {
if (originalIndices == null) {
return null;
}
return originalIndices.indicesOptions();
}

}

public static class SearchFreeContextResponse extends TransportResponse {

private static final SearchFreeContextResponse FREED = new SearchFreeContextResponse(true);
Expand Down Expand Up @@ -400,12 +434,13 @@ public static void registerRequestHandler(TransportService transportService, Sea
);

// TODO: remove this handler once the lowest compatible version stops using it
transportService.registerRequestHandler(FREE_CONTEXT_ACTION_NAME, freeContextExecutor, in -> {
var res = new ScrollFreeContextRequest(in);
// this handler exists for BwC purposes only, we don't need the original indices to free the context
OriginalIndices.readOriginalIndices(in);
return res;
}, freeContextHandler);
// this handler exists for BwC purposes only, we don't need the original indices to free the context
transportService.registerRequestHandler(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not too proud of exposing this infrastructure just for a one-off fix to be honest. But then again, hiding it behind some utility method and adding a single-use abstraction for the action-to-action translation seemed even worse. This solution is the minimum amount of code needed as far as I can tell which is quite helpful.

FREE_CONTEXT_ACTION_NAME,
freeContextExecutor,
SearchFreeContextRequest::new,
freeContextHandler
);
TransportActionProxy.registerProxyAction(transportService, FREE_CONTEXT_ACTION_NAME, false, SearchFreeContextResponse::readFrom);

transportService.registerRequestHandler(
Expand Down