Skip to content

Commit

Permalink
Fork building snapshot status response off of transport thread (elast…
Browse files Browse the repository at this point in the history
…ic#90651)

This can take O(10s) for tens of thousands of shards, we have to fork it.
relates elastic#77466
  • Loading branch information
original-brownbear committed Oct 5, 2022
1 parent 356039d commit 78f29cc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/90651.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 90651
summary: Fork building snapshot status response off of transport thread
area: Snapshot/Restore
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 78f29cc

Please sign in to comment.