Skip to content
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

Dispatch ClusterStateAction#buildResponse to executor #103435

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/103435.yaml
@@ -0,0 +1,5 @@
pr: 103435
summary: Dispatch `ClusterStateAction#buildResponse` to executor
area: Distributed
type: bug
issues: []
Expand Up @@ -11,6 +11,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRunnable;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
import org.elasticsearch.cluster.ClusterState;
Expand Down Expand Up @@ -112,7 +113,7 @@ public void onNewClusterState(ClusterState newState) {
}

if (acceptableClusterStatePredicate.test(newState)) {
ActionListener.completeWith(listener, () -> buildResponse(request, newState));
executor.execute(ActionRunnable.supply(listener, () -> buildResponse(request, newState)));
} else {
listener.onFailure(
new NotMasterException(
Expand Down Expand Up @@ -150,6 +151,8 @@ private static Map<String, Set<String>> getClusterFeatures(ClusterState clusterS
}

private ClusterStateResponse buildResponse(final ClusterStateRequest request, final ClusterState currentState) {
ThreadPool.assertCurrentThreadPool(ThreadPool.Names.MANAGEMENT); // too heavy to construct & serialize cluster state without forking

logger.trace("Serving cluster state request using version {}", currentState.version());
ClusterState.Builder builder = ClusterState.builder(currentState.getClusterName());
builder.version(currentState.version());
Expand Down