Skip to content

Commit 537a1c9

Browse files
authored
Capture max processors in static init (#97119) (#97153)
The number of processors available to the jvm can change over time. However, most of Elasticsearch assumes this value is constant. Although we could rework all code relying on the number of processors to dynamically support updates and poll the jvm, doing so has little value since the processors changing is an edge case. Instead, this commit fixes validation of the node.processors setting (our internal number of processors) to validate based on the max processors available at launch. closes #97088
1 parent 62579b0 commit 537a1c9

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

docs/changelog/97119.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 97119
2+
summary: Capture max processors in static init
3+
area: Infra/Core
4+
type: bug
5+
issues:
6+
- 97088

server/src/main/java/org/elasticsearch/common/util/concurrent/EsExecutors.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@ public class EsExecutors {
4040

4141
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(EsExecutors.class);
4242

43+
// although the available processors may technically change, for node sizing we use the number available at launch
44+
private static final int MAX_NUM_PROCESSORS = Runtime.getRuntime().availableProcessors();
45+
4346
/**
4447
* Setting to manually set the number of available processors. This setting is used to adjust thread pool sizes per node.
4548
*/
4649
public static final Setting<Integer> PROCESSORS_SETTING = new Setting<>(
4750
"processors",
48-
s -> Integer.toString(Runtime.getRuntime().availableProcessors()),
51+
s -> Integer.toString(MAX_NUM_PROCESSORS),
4952
processorsParser("processors"),
5053
Property.Deprecated,
5154
Property.NodeScope
@@ -66,7 +69,7 @@ public class EsExecutors {
6669
private static Function<String, Integer> processorsParser(final String name) {
6770
return s -> {
6871
final int value = Setting.parseInt(s, 1, name);
69-
final int availableProcessors = Runtime.getRuntime().availableProcessors();
72+
final int availableProcessors = MAX_NUM_PROCESSORS;
7073
if (value > availableProcessors) {
7174
deprecationLogger.critical(
7275
DeprecationCategory.SETTINGS,

0 commit comments

Comments
 (0)