Clamp merge scheduler thread count when it exceeds max merge count - #155693
Clamp merge scheduler thread count when it exceeds max merge count#155693reugn wants to merge 2 commits into
Conversation
|
Pinging @elastic/es-search-foundations (Team:Search Foundations) |
|
Hi @reugn, I've created a changelog YAML for you. |
✅ Elastic Docs Style Checker (Vale)No issues found on modified lines! The Vale linter checks documentation changes against the Elastic Docs style guide. To use Vale locally or report issues, refer to Elastic style guide for Vale. |
🔍 Preview links for changed docs |
ℹ️ Important: Docs version tagging👋 Thanks for updating the docs! Just a friendly reminder that our docs are now cumulative. This means all 9.x versions are documented on the same page and published off of the main branch, instead of creating separate pages for each minor version. We use applies_to tags to mark version-specific features and changes. Expand for a quick overviewWhen to use applies_to tags:✅ At the page level to indicate which products/deployments the content applies to (mandatory) What NOT to do:❌ Don't remove or replace information that applies to an older version 🤔 Need help?
|
| if (indexToDefaultSettings != null) { | ||
| Settings defaultSettings = settingsFilter.filter(indexScopedSettings.diff(indexMetadata.getSettings(), Settings.EMPTY)); | ||
| // Include node settings so defaults that depend on them (e.g. node.processors) resolve. | ||
| final Settings settingsForDefaults = Settings.builder().put(nodeSettings).put(indexMetadata.getSettings()).build(); |
There was a problem hiding this comment.
This seems deeply suspicious. It doesn't make sense to merge node-scoped settings with index-scoped settings like this.
I'd rather we stuck with today's behaviour in which index.merge.scheduler.max_thread_count is independent of the node-scoped node.processors setting, but clarified this independence thusly:
diff --git a/server/src/main/java/org/elasticsearch/index/MergeSchedulerConfig.java b/server/src/main/java/org/elasticsearch/index/MergeSchedulerConfig.java
index b182bba82733..bd97ad8a2723 100644
--- a/server/src/main/java/org/elasticsearch/index/MergeSchedulerConfig.java
+++ b/server/src/main/java/org/elasticsearch/index/MergeSchedulerConfig.java
@@ -45,7 +45,7 @@ public final class MergeSchedulerConfig {
public static final Setting<Integer> MAX_THREAD_COUNT_SETTING = new Setting<>(
"index.merge.scheduler.max_thread_count",
- (s) -> Integer.toString(Math.max(1, EsExecutors.allocatedProcessors(s) / 2)),
+ (s) -> Integer.toString(Math.max(1, Runtime.getRuntime().availableProcessors() / 2)),
(s) -> Setting.parseInt(s, 1, "index.merge.scheduler.max_thread_count"),
Property.Dynamic,
Property.IndexScopeThere was a problem hiding this comment.
Just to confirm, are you good with not honoring node.processors for the thread count default (use availableProcessors() instead)?
If so I'll drop the settings merge in TransportGetSettingsAction, MergeSchedulerConfig, and IndexSettings, and keep this PR to the clamp.
There was a problem hiding this comment.
Just to confirm, are you good with not honoring node.processors for the thread count default (use availableProcessors() instead)?
Yes. AFAICT that's how this has behaved for at least a decade. I'm not sure it's ever actually respected node.processors.
| ); | ||
| } | ||
| this.maxThreadCount = maxThreadCount; | ||
| this.maxThreadCount = Math.min(maxThreadCount, maxMergeCount); |
There was a problem hiding this comment.
I think we should emit a warning in the logs when this clamping takes effect. It will be surprising to users if they try and increase the max thread count and Elasticsearch just silently ignores them. I'm ok with clamping (i.e. ignoring the invalid config) as long as it's not silent.
Bad
index.merge.schedulercombinations could throw while buildingIndexSettingsduring cluster-state application (including index deletion), so a node stopped applying later states. The usual case is an explicitmax_merge_countwith a defaultmax_thread_countderived from the local processor count, which can be higher on some nodes than on the master that accepted the setting. The default also ignorednode.processorsbecause it was resolved from index settings alone.This change clamps
max_thread_counttomax_merge_counton apply so published settings are always accepted, resolves those defaults from merged node+index settings, and rejects create/update requests only when both values are set explicitly and inverted.include_defaultson get-settings now merges node settings so the reported default matches.Closes #96594
Closes #155678