From 78f29cca313d0ce40a5bced423267672530238f5 Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Wed, 5 Oct 2022 11:26:21 +0200 Subject: [PATCH] Fork building snapshot status response off of transport thread (#90651) This can take O(10s) for tens of thousands of shards, we have to fork it. relates #77466 --- docs/changelog/90651.yaml | 5 ++++ .../TransportSnapshotsStatusAction.java | 27 ++++++++++++------- 2 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 docs/changelog/90651.yaml diff --git a/docs/changelog/90651.yaml b/docs/changelog/90651.yaml new file mode 100644 index 0000000000000..9bbb26772ae4b --- /dev/null +++ b/docs/changelog/90651.yaml @@ -0,0 +1,5 @@ +pr: 90651 +summary: Fork building snapshot status response off of transport thread +area: Snapshot/Restore +type: bug +issues: [] diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java index 5c079d430458e..55e98327a0a47 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java @@ -13,6 +13,7 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.StepListener; import org.elasticsearch.action.support.ActionFilters; +import org.elasticsearch.action.support.ThreadedActionListener; import org.elasticsearch.action.support.master.TransportMasterNodeAction; import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.cluster.ClusterState; @@ -90,7 +91,7 @@ public TransportSnapshotsStatusAction( SnapshotsStatusRequest::new, indexNameExpressionResolver, SnapshotsStatusResponse::new, - ThreadPool.Names.SAME + ThreadPool.Names.SNAPSHOT_META // building the response is somewhat expensive for large snapshots so we fork ); this.repositoriesService = repositoriesService; this.client = client; @@ -141,16 +142,22 @@ protected void masterOperation( TransportNodesSnapshotsStatus.TYPE, new TransportNodesSnapshotsStatus.Request(nodesIds.toArray(Strings.EMPTY_ARRAY)).snapshots(snapshots) .timeout(request.masterNodeTimeout()), - ActionListener.wrap( - nodeSnapshotStatuses -> buildResponse( - snapshotsInProgress, - request, - currentSnapshots, - nodeSnapshotStatuses, - cancellableTask, - listener + new ThreadedActionListener<>( + logger, + threadPool, + ThreadPool.Names.SNAPSHOT_META, // fork to snapshot meta since building the response is expensive for large snapshots + ActionListener.wrap( + nodeSnapshotStatuses -> buildResponse( + snapshotsInProgress, + request, + currentSnapshots, + nodeSnapshotStatuses, + cancellableTask, + listener + ), + listener::onFailure ), - listener::onFailure + false ) ); } else {