Skip to content

Fork CCS search-shards handling #98209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2023
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
5 changes: 5 additions & 0 deletions docs/changelog/98209.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 98209
summary: Fork CCS search-shards handling
area: Search
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public TransportClusterSearchShardsAction(
ClusterSearchShardsRequest::new,
indexNameExpressionResolver,
ClusterSearchShardsResponse::new,
ThreadPool.Names.SAME
ThreadPool.Names.SEARCH_COORDINATION
);
this.indicesService = indicesService;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
import org.elasticsearch.transport.RemoteTransportException;
import org.elasticsearch.transport.Transport;
import org.elasticsearch.transport.TransportRequestOptions;
import org.elasticsearch.transport.TransportResponseHandler;
import org.elasticsearch.transport.TransportService;

import java.util.ArrayList;
Expand Down Expand Up @@ -648,6 +647,7 @@ static void collectSearchShards(
) {
@Override
void innerOnResponse(SearchShardsResponse searchShardsResponse) {
assert ThreadPool.assertCurrentThreadPool(ThreadPool.Names.SEARCH_COORDINATION);
searchShardsResponses.put(clusterAlias, searchShardsResponse);
}

Expand All @@ -661,6 +661,7 @@ Map<String, SearchShardsResponse> createFinalResponse() {
skipUnavailable == false,
ActionListener.wrap(connection -> {
final String[] indices = entry.getValue().indices();
final Executor responseExecutor = transportService.getThreadPool().executor(ThreadPool.Names.SEARCH_COORDINATION);
// TODO: support point-in-time
if (searchContext == null && connection.getTransportVersion().onOrAfter(TransportVersion.V_8_500_010)) {
SearchShardsRequest searchShardsRequest = new SearchShardsRequest(
Expand All @@ -677,11 +678,7 @@ Map<String, SearchShardsResponse> createFinalResponse() {
SearchShardsAction.NAME,
searchShardsRequest,
TransportRequestOptions.EMPTY,
new ActionListenerResponseHandler<>(
singleListener,
SearchShardsResponse::new,
TransportResponseHandler.TRANSPORT_WORKER
)
new ActionListenerResponseHandler<>(singleListener, SearchShardsResponse::new, responseExecutor)
);
} else {
ClusterSearchShardsRequest searchShardsRequest = new ClusterSearchShardsRequest(indices).indicesOptions(
Expand All @@ -695,7 +692,7 @@ Map<String, SearchShardsResponse> createFinalResponse() {
new ActionListenerResponseHandler<>(
singleListener.map(SearchShardsResponse::fromLegacyResponse),
ClusterSearchShardsResponse::new,
TransportResponseHandler.TRANSPORT_WORKER
responseExecutor
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public TransportSearchShardsAction(
SearchTransportService searchTransportService,
IndexNameExpressionResolver indexNameExpressionResolver
) {
super(SearchShardsAction.NAME, transportService, actionFilters, SearchShardsRequest::new);
super(SearchShardsAction.NAME, transportService, actionFilters, SearchShardsRequest::new, ThreadPool.Names.SEARCH_COORDINATION);
this.transportService = transportService;
this.transportSearchAction = transportSearchAction;
this.searchService = searchService;
Expand All @@ -73,6 +73,7 @@ public TransportSearchShardsAction(

@Override
protected void doExecute(Task task, SearchShardsRequest searchShardsRequest, ActionListener<SearchShardsResponse> listener) {
assert ThreadPool.assertCurrentThreadPool(ThreadPool.Names.SEARCH_COORDINATION);
final long relativeStartNanos = System.nanoTime();
SearchRequest original = new SearchRequest(searchShardsRequest.indices()).indicesOptions(searchShardsRequest.indicesOptions())
.routing(searchShardsRequest.routing())
Expand Down