Skip to content

Commit 537f4e1

Browse files
committed
Deprecate bootstrap.mlockall
The setting bootstrap.mlockall is useful on both POSIX-like systems (POSIX mlockall) and Windows (Win32 VirtualLock). But mlockall is really a POSIX only thing so the name should not be tied POSIX. This commit deprecates the setting in favor of "bootstrap.memory_lock". Relates #18671
1 parent e756470 commit 537f4e1

File tree

7 files changed

+33
-6
lines changed

7 files changed

+33
-6
lines changed

core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.elasticsearch.common.cli.Terminal;
2929
import org.elasticsearch.common.inject.CreationException;
3030
import org.elasticsearch.common.lease.Releasables;
31+
import org.elasticsearch.common.logging.DeprecationLogger;
3132
import org.elasticsearch.common.logging.ESLogger;
3233
import org.elasticsearch.common.logging.Loggers;
3334
import org.elasticsearch.common.logging.log4j.LogConfigurator;
@@ -141,8 +142,23 @@ static void initializeProbes() {
141142
}
142143

143144
private void setup(boolean addShutdownHook, Settings settings, Environment environment) throws Exception {
145+
final ESLogger logger = Loggers.getLogger(Bootstrap.class);
146+
final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);
147+
148+
final Boolean mlockall = settings.getAsBoolean("bootstrap.mlockall", null);
149+
if (mlockall != null) {
150+
deprecationLogger.deprecated("setting [bootstrap.mlockall] is deprecated; use [bootstrap.memory_lock]");
151+
}
152+
153+
final Boolean memoryLock = settings.getAsBoolean("bootstrap.memory_lock", null);
154+
// both bootstrap.mlockall and bootstrap.memory_lock are set, refuse to start
155+
if (mlockall != null && memoryLock != null) {
156+
throw new IllegalArgumentException("both [bootstrap.mlockall] and [bootstrap.memory_lock] configured,"
157+
+ " just use [bootstrap.memory_lock]");
158+
}
159+
144160
initializeNatives(environment.tmpFile(),
145-
settings.getAsBoolean("bootstrap.mlockall", false),
161+
memoryLock != null ? memoryLock : mlockall != null ? mlockall : false,
146162
settings.getAsBoolean("bootstrap.seccomp", true),
147163
settings.getAsBoolean("bootstrap.ctrlhandler", true));
148164

distribution/src/main/packaging/env/elasticsearch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ ES_STARTUP_SLEEP_TIME=${packaging.elasticsearch.startup.sleep.time}
6363
#MAX_OPEN_FILES=${packaging.os.max.open.files}
6464

6565
# The maximum number of bytes of memory that may be locked into RAM
66-
# Set to "unlimited" if you use the 'bootstrap.mlockall: true' option
66+
# Set to "unlimited" if you use the 'bootstrap.memory_lock: true' option
6767
# in elasticsearch.yml (ES_HEAP_SIZE must also be set).
6868
# When using Systemd, the LimitMEMLOCK property must be set
6969
# in ${packaging.elasticsearch.systemd.dir}/elasticsearch.service

distribution/src/main/packaging/systemd/elasticsearch.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ StandardError=inherit
3333
LimitNOFILE=${packaging.os.max.open.files}
3434

3535
# Specifies the maximum number of bytes of memory that may be locked into RAM
36-
# Set to "infinity" if you use the 'bootstrap.mlockall: true' option
36+
# Set to "infinity" if you use the 'bootstrap.memory_lock: true' option
3737
# in elasticsearch.yml and 'MAX_LOCKED_MEMORY=unlimited' in ${packaging.env.file}
3838
#LimitMEMLOCK=infinity
3939

distribution/src/main/resources/config/elasticsearch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#
4141
# Lock the memory on startup:
4242
#
43-
# bootstrap.mlockall: true
43+
# bootstrap.memory_lock: true
4444
#
4545
# Make sure that the `ES_HEAP_SIZE` environment variable is set to about half the memory
4646
# available on the system and that the owner of the process is allowed to use this limit.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[[breaking-changes-2.4]]
2+
== Breaking changes in 2.4
3+
4+
[[breaking_24_settings]]
5+
[float]
6+
=== Settings
7+
8+
The setting `bootstrap.mlockall` has been renamed to
9+
<<bootstrap.memory_lock,`bootstrap.memory_lock`>>. Future versions of
10+
Elasticsearch will refuse to start if `bootstrap.mlockall` is set. You
11+
can switch to the new setting now.

docs/reference/setup/as-a-service.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Each package features a configuration file, which allows you to set the followin
1717
`ES_HEAP_NEWSIZE`:: The size of the new generation heap
1818
`ES_DIRECT_SIZE`:: The maximum size of the direct memory
1919
`MAX_OPEN_FILES`:: Maximum number of open files, defaults to `65536`
20-
`MAX_LOCKED_MEMORY`:: Maximum locked memory size. Set to "unlimited" if you use the bootstrap.mlockall option in elasticsearch.yml. You must also set ES_HEAP_SIZE.
20+
`MAX_LOCKED_MEMORY`:: Maximum locked memory size. Set to "unlimited" if you use the bootstrap.memory_lock option in elasticsearch.yml. You must also set ES_HEAP_SIZE.
2121
`MAX_MAP_COUNT`:: Maximum number of memory map areas a process may have. If you use `mmapfs` as index store type, make sure this is set to a high value. For more information, check the https://github.com/torvalds/linux/blob/master/Documentation/sysctl/vm.txt[linux kernel documentation] about `max_map_count`. This is set via `sysctl` before starting elasticsearch. Defaults to `65535`
2222
`LOG_DIR`:: Log directory, defaults to `/var/log/elasticsearch`
2323
`DATA_DIR`:: Data directory, defaults to `/var/lib/elasticsearch`

docs/reference/setup/configuration.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ to the `config/elasticsearch.yml` file:
121121

122122
[source,yaml]
123123
--------------
124-
bootstrap.mlockall: true
124+
bootstrap.memory_lock: true
125125
--------------
126126

127127
After starting Elasticsearch, you can see whether this setting was applied

0 commit comments

Comments
 (0)