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

Remove search throttled index setting and thread pool #124519

Merged
merged 6 commits into from
Mar 14, 2025
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
1 change: 1 addition & 0 deletions rest-api-spec/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,5 @@ tasks.named("yamlRestCompatTestTransform").configure ({ task ->
task.skipTest("indices.create/21_synthetic_source_stored/index param - field ordering", "Synthetic source keep arrays now stores leaf arrays natively")
task.skipTest("indices.create/21_synthetic_source_stored/field param - keep nested array", "Synthetic source keep arrays now stores leaf arrays natively")
task.skipTest("indices.create/21_synthetic_source_stored/field param - keep root array", "Synthetic source keep arrays now stores leaf arrays natively")
task.skipTest("cluster.info/30_info_thread_pool/Cluster HTTP Info", "The search_throttled thread pool has been removed")
})
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,6 @@
- gte: { thread_pool.search_coordination.largest: 0 }
- gte: { thread_pool.search_coordination.completed: 0 }

- gte: { thread_pool.search_throttled.threads: 0 }
- gte: { thread_pool.search_throttled.queue: 0 }
- gte: { thread_pool.search_throttled.active: 0 }
- gte: { thread_pool.search_throttled.rejected: 0 }
- gte: { thread_pool.search_throttled.largest: 0 }
- gte: { thread_pool.search_throttled.completed: 0 }

- gte: { thread_pool.snapshot.threads: 0 }
- gte: { thread_pool.snapshot.queue: 0 }
- gte: { thread_pool.snapshot.active: 0 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@

import java.io.IOException;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.function.LongSupplier;

/**
Expand Down Expand Up @@ -184,12 +183,4 @@ protected ShardIterator shards(ProjectState state, InternalRequest request) {
return clusterService.operationRouting()
.getShards(state, request.concreteIndex(), request.request().id(), request.request().routing(), request.request().preference());
}

@Override
protected Executor getExecutor(ExplainRequest request, ShardId shardId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request is not used in the parent class or subclasses.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting catch, yes, that may mean we can refactor this further perhaps and remove the request argument, not too sure why it's there in the first place.

IndexService indexService = searchService.getIndicesService().indexServiceSafe(shardId.getIndex());
return indexService.getIndexSettings().isSearchThrottled()
? threadPool.executor(ThreadPool.Names.SEARCH_THROTTLED)
: super.getExecutor(request, shardId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,6 @@ protected Executor getExecutor(GetRequest request, ShardId shardId) {
final ClusterState clusterState = clusterService.state();
if (projectResolver.getProjectMetadata(clusterState).getIndexSafe(shardId.getIndex()).isSystem()) {
return threadPool.executor(executorSelector.executorForGet(shardId.getIndexName()));
} else if (indicesService.indexServiceSafe(shardId.getIndex()).getIndexSettings().isSearchThrottled()) {
return threadPool.executor(ThreadPool.Names.SEARCH_THROTTLED);
} else {
return super.getExecutor(request, shardId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ protected Executor getExecutor(MultiGetShardRequest request, ShardId shardId) {
final ClusterState clusterState = clusterService.state();
if (projectResolver.getProjectMetadata(clusterState).index(shardId.getIndex()).isSystem()) {
return threadPool.executor(executorSelector.executorForGet(shardId.getIndexName()));
} else if (indicesService.indexServiceSafe(shardId.getIndex()).getIndexSettings().isSearchThrottled()) {
return threadPool.executor(ThreadPool.Names.SEARCH_THROTTLED);
} else {
return super.getExecutor(request, shardId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;

import java.util.concurrent.Executor;

import static org.elasticsearch.core.Strings.format;

public class TransportShardMultiTermsVectorAction extends TransportSingleShardAction<
Expand Down Expand Up @@ -112,12 +110,4 @@ protected MultiTermVectorsShardResponse shardOperation(MultiTermVectorsShardRequ

return response;
}

@Override
protected Executor getExecutor(MultiTermVectorsShardRequest request, ShardId shardId) {
IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex());
return indexService.getIndexSettings().isSearchThrottled()
? threadPool.executor(ThreadPool.Names.SEARCH_THROTTLED)
: super.getExecutor(request, shardId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.elasticsearch.transport.TransportService;

import java.io.IOException;
import java.util.concurrent.Executor;

/**
* Performs the get operation.
Expand Down Expand Up @@ -127,12 +126,4 @@ protected TermVectorsResponse shardOperation(TermVectorsRequest request, ShardId
protected Writeable.Reader<TermVectorsResponse> getResponseReader() {
return TermVectorsResponse::new;
}

@Override
protected Executor getExecutor(TermVectorsRequest request, ShardId shardId) {
IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex());
return indexService.getIndexSettings().isSearchThrottled()
? threadPool.executor(ThreadPool.Names.SEARCH_THROTTLED)
: super.getExecutor(request, shardId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ public final class IndexScopedSettings extends AbstractScopedSettings {
IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING,
IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING,
IndexSettings.INDEX_SEARCH_IDLE_AFTER,
IndexSettings.INDEX_SEARCH_THROTTLED,
IndexFieldDataService.INDEX_FIELDDATA_CACHE_KEY,
IndexSettings.IGNORE_ABOVE_SETTING,
FieldMapper.IGNORE_MALFORMED_SETTING,
Expand Down
26 changes: 0 additions & 26 deletions server/src/main/java/org/elasticsearch/index/IndexSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -538,17 +538,6 @@ public Iterator<Setting<?>> settings() {
Property.ServerlessPublic
);

/**
* Marks an index to be searched throttled. This means that never more than one shard of such an index will be searched concurrently
*/
public static final Setting<Boolean> INDEX_SEARCH_THROTTLED = Setting.boolSetting(
"index.search.throttled",
false,
Property.IndexScope,
Property.PrivateIndex,
Property.Dynamic
);

/**
* Determines a balance between file-based and operations-based peer recoveries. The number of operations that will be used in an
* operations-based peer recovery is limited to this proportion of the total number of documents in the shard (including deleted
Expand Down Expand Up @@ -913,7 +902,6 @@ private void setRetentionLeaseMillis(final TimeValue retentionLease) {
private volatile int maxTermsCount;
private volatile String defaultPipeline;
private volatile String requiredPipeline;
private volatile boolean searchThrottled;
private volatile long mappingNestedFieldsLimit;
private volatile long mappingNestedDocsLimit;
private volatile long mappingTotalFieldsLimit;
Expand Down Expand Up @@ -1042,7 +1030,6 @@ public IndexSettings(final IndexMetadata indexMetadata, final Settings nodeSetti
this.timestampBounds = TimestampBounds.updateEndTime(this.timestampBounds, endTime);
});
}
this.searchThrottled = INDEX_SEARCH_THROTTLED.get(settings);
this.queryStringLenient = QUERY_STRING_LENIENT_SETTING.get(settings);
this.queryStringAnalyzeWildcard = QUERY_STRING_ANALYZE_WILDCARD.get(nodeSettings);
this.queryStringAllowLeadingWildcard = QUERY_STRING_ALLOW_LEADING_WILDCARD.get(nodeSettings);
Expand Down Expand Up @@ -1200,7 +1187,6 @@ public IndexSettings(final IndexMetadata indexMetadata, final Settings nodeSetti
scopedSettings.addSettingsUpdateConsumer(DEFAULT_PIPELINE, this::setDefaultPipeline);
scopedSettings.addSettingsUpdateConsumer(FINAL_PIPELINE, this::setRequiredPipeline);
scopedSettings.addSettingsUpdateConsumer(INDEX_SOFT_DELETES_RETENTION_OPERATIONS_SETTING, this::setSoftDeleteRetentionOperations);
scopedSettings.addSettingsUpdateConsumer(INDEX_SEARCH_THROTTLED, this::setSearchThrottled);
scopedSettings.addSettingsUpdateConsumer(INDEX_SOFT_DELETES_RETENTION_LEASE_PERIOD_SETTING, this::setRetentionLeaseMillis);
scopedSettings.addSettingsUpdateConsumer(INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING, this::setMappingNestedFieldsLimit);
scopedSettings.addSettingsUpdateConsumer(INDEX_MAPPING_NESTED_DOCS_LIMIT_SETTING, this::setMappingNestedDocsLimit);
Expand Down Expand Up @@ -1725,18 +1711,6 @@ public long getSoftDeleteRetentionOperations() {
return this.softDeleteRetentionOperations;
}

/**
* Returns true if the this index should be searched throttled ie. using the
* {@link org.elasticsearch.threadpool.ThreadPool.Names#SEARCH_THROTTLED} thread-pool
*/
public boolean isSearchThrottled() {
return searchThrottled;
}

private void setSearchThrottled(boolean searchThrottled) {
this.searchThrottled = searchThrottled;
}

public long getMappingNestedFieldsLimit() {
return mappingNestedFieldsLimit;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,14 @@ private static void addBwcSearchWorkerSettings(List<Setting<?>> additionalSettin
additionalSettings.add(
Setting.intSetting("thread_pool.search_worker.size", 0, Setting.Property.NodeScope, Setting.Property.DeprecatedWarning)
);
// Search throttled thread pool has been removed in Elasticsearch 9.0.0. These settings are deprecated and take no effect.
// They are here only to enable BwC for deployments that still use them
additionalSettings.add(
Setting.intSetting("thread_pool.search_throttled.queue_size", 0, Setting.Property.NodeScope, Setting.Property.DeprecatedWarning)
);
additionalSettings.add(
Setting.intSetting("thread_pool.search_throttled.size", 0, Setting.Property.NodeScope, Setting.Property.DeprecatedWarning)
);
}

private SearchModule createSearchModule(Settings settings, ThreadPool threadPool, TelemetryProvider telemetryProvider) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestResponse;
import org.elasticsearch.rest.Scope;
Expand Down Expand Up @@ -125,7 +124,6 @@ public RestResponse buildResponse(Void ignored) throws Exception {
.prepareGetSettings(masterNodeTimeout, indices)
.setIndicesOptions(indicesOptions)
.setMasterNodeTimeout(masterNodeTimeout)
.setNames(IndexSettings.INDEX_SEARCH_THROTTLED.getKey())
.execute(listeners.acquire(indexSettingsRef::set));

// The other requests just provide additional detail, and wildcards may be resolved differently depending on the type of
Expand Down Expand Up @@ -488,8 +486,6 @@ protected Table getTableWithHeader(final RestRequest request) {
table.addCell("memory.total", "sibling:pri;alias:tm,memoryTotal;default:false;text-align:right;desc:total used memory");
table.addCell("pri.memory.total", "default:false;text-align:right;desc:total user memory");

table.addCell("search.throttled", "alias:sth;default:false;desc:indicates if the index is search throttled");

table.addCell(
"bulk.total_operations",
"sibling:pri;alias:bto,bulkTotalOperation;default:false;text-align:right;desc:number of bulk shard ops"
Expand Down Expand Up @@ -568,7 +564,6 @@ Table buildTable(

final IndexMetadata.State indexState = indexMetadata.getState();
final IndexStats indexStats = indicesStats.get(indexName);
final boolean searchThrottled = IndexSettings.INDEX_SEARCH_THROTTLED.get(settings);

final IndexRoutingTable indexRoutingTable = clusterState.routingTable(project.id()).index(indexName);
final ClusterHealthStatus indexHealthStatus = indexRoutingTable == null
Expand Down Expand Up @@ -803,8 +798,6 @@ Table buildTable(
table.addCell(totalStats.getTotalMemory());
table.addCell(primaryStats.getTotalMemory());

table.addCell(searchThrottled);

table.addCell(totalStats.getBulk() == null ? null : totalStats.getBulk().getTotalOperations());
table.addCell(primaryStats.getBulk() == null ? null : primaryStats.getBulk().getTotalOperations());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -957,8 +957,6 @@ private Executor getExecutor(IndexShard indexShard) {
final String executorName;
if (indexShard.isSystem()) {
executorName = executorSelector.executorForSearch(indexShard.shardId().getIndexName());
} else if (indexShard.indexSettings().isSearchThrottled()) {
executorName = Names.SEARCH_THROTTLED;
} else {
executorName = Names.SEARCH;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ public Map<String, ExecutorBuilder> getBuilders(Settings settings, int allocated
EsExecutors.TaskTrackingConfig.DEFAULT
)
);
result.put(
ThreadPool.Names.SEARCH_THROTTLED,
new FixedExecutorBuilder(settings, ThreadPool.Names.SEARCH_THROTTLED, 1, 100, EsExecutors.TaskTrackingConfig.DEFAULT)
);
result.put(
ThreadPool.Names.MANAGEMENT,
new ScalingExecutorBuilder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ public static class Names {
public static final String SEARCH = "search";
public static final String SEARCH_COORDINATION = "search_coordination";
public static final String AUTO_COMPLETE = "auto_complete";
public static final String SEARCH_THROTTLED = "search_throttled";

/**
* A thread pool for running tasks related to cluster management, including collecting and exposing stats in APIs and certain other
* internal tasks.
Expand Down Expand Up @@ -197,7 +195,6 @@ public static ThreadPoolType fromType(String type) {
entry(Names.FORCE_MERGE, ThreadPoolType.FIXED),
entry(Names.FETCH_SHARD_STARTED, ThreadPoolType.SCALING),
entry(Names.FETCH_SHARD_STORE, ThreadPoolType.SCALING),
entry(Names.SEARCH_THROTTLED, ThreadPoolType.FIXED),
entry(Names.SYSTEM_READ, ThreadPoolType.FIXED),
entry(Names.SYSTEM_WRITE, ThreadPoolType.FIXED),
entry(Names.SYSTEM_CRITICAL_READ, ThreadPoolType.FIXED),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.elasticsearch.core.Tuple;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.indices.IndexClosedException;
import org.elasticsearch.indices.InvalidIndexNameException;
Expand Down Expand Up @@ -2279,7 +2278,7 @@ public void testIgnoreThrottled() {
.putAlias(AliasMetadata.builder("test-alias"))
)
.put(
indexBuilder("index", Settings.builder().put(IndexSettings.INDEX_SEARCH_THROTTLED.getKey(), true).build()).state(State.OPEN)
indexBuilder("index", Settings.builder().put("index.search.throttled", true).build()).state(State.OPEN)
.putAlias(AliasMetadata.builder("test-alias2"))
)
.put(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.elasticsearch.common.UUIDs;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESTestCase;
Expand Down Expand Up @@ -62,7 +61,6 @@ public void testBuildTable() {
Settings indexSettings = Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
.put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID())
.put(IndexSettings.INDEX_SEARCH_THROTTLED.getKey(), randomBoolean())
.build();
indicesSettings.put(indexName, indexSettings);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.AbstractRefCounted;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexModule;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.IndexService;
Expand Down Expand Up @@ -167,7 +166,6 @@
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertResponse;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHits;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
Expand Down Expand Up @@ -1846,46 +1844,6 @@ public void testCanRewriteToMatchNone() {
);
}

public void testSetSearchThrottled() throws IOException {
createIndex("throttled_threadpool_index");
client().execute(
InternalOrPrivateSettingsPlugin.UpdateInternalOrPrivateAction.INSTANCE,
new InternalOrPrivateSettingsPlugin.UpdateInternalOrPrivateAction.Request(
"throttled_threadpool_index",
IndexSettings.INDEX_SEARCH_THROTTLED.getKey(),
"true"
)
).actionGet();
final SearchService service = getInstanceFromNode(SearchService.class);
Index index = resolveIndex("throttled_threadpool_index");
assertTrue(service.getIndicesService().indexServiceSafe(index).getIndexSettings().isSearchThrottled());
prepareIndex("throttled_threadpool_index").setId("1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
assertSearchHits(
client().prepareSearch("throttled_threadpool_index")
.setIndicesOptions(IndicesOptions.STRICT_EXPAND_OPEN_FORBID_CLOSED)
.setSize(1),
"1"
);
// we add a search action listener in a plugin above to assert that this is actually used
client().execute(
InternalOrPrivateSettingsPlugin.UpdateInternalOrPrivateAction.INSTANCE,
new InternalOrPrivateSettingsPlugin.UpdateInternalOrPrivateAction.Request(
"throttled_threadpool_index",
IndexSettings.INDEX_SEARCH_THROTTLED.getKey(),
"false"
)
).actionGet();

IllegalArgumentException iae = expectThrows(
IllegalArgumentException.class,
() -> indicesAdmin().prepareUpdateSettings("throttled_threadpool_index")
.setSettings(Settings.builder().put(IndexSettings.INDEX_SEARCH_THROTTLED.getKey(), false))
.get()
);
assertEquals("can not update private setting [index.search.throttled]; this setting is managed by Elasticsearch", iae.getMessage());
assertFalse(service.getIndicesService().indexServiceSafe(index).getIndexSettings().isSearchThrottled());
}

public void testAggContextGetsMatchAll() throws IOException {
createIndex("test");
withAggregationContext("test", context -> assertThat(context.query(), equalTo(new MatchAllDocsQuery())));
Expand Down Expand Up @@ -1937,22 +1895,6 @@ private void withAggregationContext(String index, Consumer<AggregationContext> c
}
}

public void testExpandSearchThrottled() {
createIndex("throttled_threadpool_index");
client().execute(
InternalOrPrivateSettingsPlugin.UpdateInternalOrPrivateAction.INSTANCE,
new InternalOrPrivateSettingsPlugin.UpdateInternalOrPrivateAction.Request(
"throttled_threadpool_index",
IndexSettings.INDEX_SEARCH_THROTTLED.getKey(),
"true"
)
).actionGet();

prepareIndex("throttled_threadpool_index").setId("1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
assertHitCount(client().prepareSearch(), 1L);
assertHitCount(client().prepareSearch().setIndicesOptions(IndicesOptions.STRICT_EXPAND_OPEN_FORBID_CLOSED), 1L);
}

public void testExpandSearchFrozen() {
String indexName = "frozen_index";
createIndex(indexName);
Expand Down
Loading