Skip to content

Commit

Permalink
Moving deprecation info API checks off the transport_worker thread (#…
Browse files Browse the repository at this point in the history
…86811) (#87043)

Doing a lot of work on the tranport_worker thread can cause the cluster to become unstable because nodes can't communicate quickly enough. With a lot of indices, the deprecation info API check can take tens of seconds. This change moves those checks off of the transport_worker thread.
  • Loading branch information
masseyke committed May 23, 2022
1 parent 94436c6 commit 9b79ae5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.core.Tuple;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.transport.Transports;
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
Expand Down Expand Up @@ -263,6 +264,7 @@ public static DeprecationInfoAction.Response from(
Map<String, List<DeprecationIssue>> pluginSettingIssues,
List<String> skipTheseDeprecatedSettings
) {
assert Transports.assertNotTransportThread("walking mappings in indexSettingsChecks is expensive");
// Allow system index access here to prevent deprecation warnings when we call this API
String[] concreteIndexNames = indexNameExpressionResolver.concreteIndexNames(state, request);
ClusterState stateWithSkippedSettingsRemoved = removeSkippedSettings(state, concreteIndexNames, skipTheseDeprecatedSettings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.GroupedActionListener;
import org.elasticsearch.action.support.ThreadedActionListener;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
import org.elasticsearch.client.internal.OriginSettingClient;
import org.elasticsearch.client.internal.node.NodeClient;
Expand Down Expand Up @@ -121,20 +122,28 @@ protected final void masterOperation(
settings,
new OriginSettingClient(client, ClientHelper.DEPRECATION_ORIGIN)
);
pluginSettingIssues(PLUGIN_CHECKERS, components, ActionListener.wrap(deprecationIssues -> {
listener.onResponse(
DeprecationInfoAction.Response.from(
state,
indexNameExpressionResolver,
request,
response,
INDEX_SETTINGS_CHECKS,
CLUSTER_SETTINGS_CHECKS,
deprecationIssues,
skipTheseDeprecations
)
);
}, listener::onFailure));
pluginSettingIssues(
PLUGIN_CHECKERS,
components,
new ThreadedActionListener<>(
logger,
client.threadPool(),
ThreadPool.Names.GENERIC,
listener.map(
deprecationIssues -> DeprecationInfoAction.Response.from(
state,
indexNameExpressionResolver,
request,
response,
INDEX_SETTINGS_CHECKS,
CLUSTER_SETTINGS_CHECKS,
deprecationIssues,
skipTheseDeprecations
)
),
false
)
);

}, listener::onFailure)
);
Expand Down

0 comments on commit 9b79ae5

Please sign in to comment.