Skip to content

Commit 75f3443

Browse files
Rename setting to enable mmap
With this commit we rename `node.store.allow_mmapfs` to `node.store.allow_mmap`. Previously this setting has controlled whether `mmapfs` could be used as a store type. With the introduction of `hybridfs` which also relies on memory-mapping, `node.store.allow_mmapfs` also applies to `hybridfs` and thus we rename it in order to convey that it is actually used to allow memory-mapping but not a specific store type. Relates #36668 Relates #37070
1 parent b2aa655 commit 75f3443

File tree

9 files changed

+31
-25
lines changed

9 files changed

+31
-25
lines changed

docs/reference/index-modules/store.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ memory mapped. All other files are opened using Lucene `NIOFSDirectory`.
7676
Similarly to `mmapfs` be sure you have allowed plenty of
7777
<<vm-max-map-count,virtual address space>>.
7878

79-
[[allow-mmapfs]]
79+
[[allow-mmap]]
8080
You can restrict the use of the `mmapfs` and the related `hybridfs` store type
81-
via the setting `node.store.allow_mmapfs`. This is a boolean setting indicating
81+
via the setting `node.store.allow_mmap`. This is a boolean setting indicating
8282
whether or not memory-mapping is allowed. The default is to allow it. This
8383
setting is useful, for example, if you are in an environment where you can not
8484
control the ability to create a lot of memory maps so you need disable the

docs/reference/migration/migrate_7_0/settings.asciidoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ of the node id. It can still be configured explicitly in `elasticsearch.yml`.
3636
available to keep the display output in APIs as `bulk` instead of `write`.
3737
These fallback settings and this system property have been removed.
3838

39+
[float]
40+
==== Disabling memory-mapping
41+
42+
* The setting `node.store.allow_mmapfs` has been renamed to `node.store.allow_mmap`.
43+
3944
[float]
4045
[[remove-http-enabled]]
4146
==== Http enabled setting removed

docs/reference/setup/bootstrap-checks.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ and is enforced on Linux only. To pass the maximum map count check, you
157157
must configure `vm.max_map_count` via `sysctl` to be at least `262144`.
158158

159159
Alternatively, the maximum map count check is only needed if you are using
160-
`mmapfs` as the <<index-modules-store,store type>> for your indices. If you
161-
<<allow-mmapfs,do not allow>> the use of `mmapfs` then this bootstrap check will
162-
not be enforced.
160+
`mmapfs` or `hybridfs` as the <<index-modules-store,store type>> for your
161+
indices. If you <<allow-mmap,do not allow>> the use of `mmap` then this
162+
bootstrap check will not be enforced.
163163

164164
=== Client JVM check
165165

server/src/main/java/org/elasticsearch/bootstrap/BootstrapChecks.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,8 @@ static class MaxMapCountCheck implements BootstrapCheck {
407407

408408
@Override
409409
public BootstrapCheckResult check(final BootstrapContext context) {
410-
// we only enforce the check if mmapfs is an allowed store type
411-
if (IndexModule.NODE_STORE_ALLOW_MMAPFS.get(context.settings())) {
410+
// we only enforce the check if a store is allowed to use mmap at all
411+
if (IndexModule.NODE_STORE_ALLOW_MMAP.get(context.settings())) {
412412
if (getMaxMapCount() != -1 && getMaxMapCount() < LIMIT) {
413413
final String message = String.format(
414414
Locale.ROOT,

server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ public void apply(Settings value, Settings current, Settings previous) {
284284
HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_OVERHEAD_SETTING,
285285
HierarchyCircuitBreakerService.ACCOUNTING_CIRCUIT_BREAKER_LIMIT_SETTING,
286286
HierarchyCircuitBreakerService.ACCOUNTING_CIRCUIT_BREAKER_OVERHEAD_SETTING,
287-
IndexModule.NODE_STORE_ALLOW_MMAPFS,
287+
IndexModule.NODE_STORE_ALLOW_MMAP,
288288
ClusterService.CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING,
289289
ClusterService.USER_DEFINED_META_DATA,
290290
SearchService.DEFAULT_SEARCH_TIMEOUT_SETTING,

server/src/main/java/org/elasticsearch/index/IndexModule.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
*/
8585
public final class IndexModule {
8686

87-
public static final Setting<Boolean> NODE_STORE_ALLOW_MMAPFS = Setting.boolSetting("node.store.allow_mmapfs", true, Property.NodeScope);
87+
public static final Setting<Boolean> NODE_STORE_ALLOW_MMAP = Setting.boolSetting("node.store.allow_mmap", true, Property.NodeScope);
8888

8989
public static final Setting<String> INDEX_STORE_TYPE_SETTING =
9090
new Setting<>("index.store.type", "", Function.identity(), Property.IndexScope, Property.NodeScope);
@@ -355,8 +355,8 @@ public interface IndexSearcherWrapperFactory {
355355
IndexSearcherWrapper newWrapper(IndexService indexService);
356356
}
357357

358-
public static Type defaultStoreType(final boolean allowMmapfs) {
359-
if (allowMmapfs && Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) {
358+
public static Type defaultStoreType(final boolean allowMmap) {
359+
if (allowMmap && Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) {
360360
return Type.HYBRIDFS;
361361
} else if (Constants.WINDOWS) {
362362
return Type.SIMPLEFS;
@@ -406,18 +406,18 @@ private static IndexStore getIndexStore(
406406
final IndexSettings indexSettings, final Map<String, Function<IndexSettings, IndexStore>> indexStoreFactories) {
407407
final String storeType = indexSettings.getValue(INDEX_STORE_TYPE_SETTING);
408408
final Type type;
409-
final Boolean allowMmapfs = NODE_STORE_ALLOW_MMAPFS.get(indexSettings.getNodeSettings());
409+
final Boolean allowMmap = NODE_STORE_ALLOW_MMAP.get(indexSettings.getNodeSettings());
410410
if (storeType.isEmpty() || Type.FS.getSettingsKey().equals(storeType)) {
411-
type = defaultStoreType(allowMmapfs);
411+
type = defaultStoreType(allowMmap);
412412
} else {
413413
if (isBuiltinType(storeType)) {
414414
type = Type.fromSettingsKey(storeType);
415415
} else {
416416
type = null;
417417
}
418418
}
419-
if (type != null && type == Type.MMAPFS && allowMmapfs == false) {
420-
throw new IllegalArgumentException("store type [mmapfs] is not allowed");
419+
if (allowMmap == false && (type == Type.MMAPFS || type == Type.HYBRIDFS)) {
420+
throw new IllegalArgumentException("store type [" + storeType + "] is not allowed because mmap is disabled");
421421
}
422422
final IndexStore store;
423423
if (storeType.isEmpty() || isBuiltinType(storeType)) {

server/src/main/java/org/elasticsearch/index/store/FsDirectoryService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ protected Directory newFSDirectory(Path location, LockFactory lockFactory) throw
8888
indexSettings.getSettings().get(IndexModule.INDEX_STORE_TYPE_SETTING.getKey(), IndexModule.Type.FS.getSettingsKey());
8989
IndexModule.Type type;
9090
if (IndexModule.Type.FS.match(storeType)) {
91-
type = IndexModule.defaultStoreType(IndexModule.NODE_STORE_ALLOW_MMAPFS.get(indexSettings.getNodeSettings()));
91+
type = IndexModule.defaultStoreType(IndexModule.NODE_STORE_ALLOW_MMAP.get(indexSettings.getNodeSettings()));
9292
} else {
9393
type = IndexModule.Type.fromSettingsKey(storeType);
9494
}

server/src/test/java/org/elasticsearch/bootstrap/MaxMapCountCheckTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,21 @@ public void testMaxMapCountCheckBelowLimitAndMemoryMapAllowed() {
7676
/*
7777
* There are two ways that memory maps are allowed:
7878
* - by default
79-
* - mmapfs is explicitly allowed
80-
* We want to test that if mmapfs is allowed then the max map count check is enforced.
79+
* - mmap is explicitly allowed
80+
* We want to test that if mmap is allowed then the max map count check is enforced.
8181
*/
8282
final List<Settings> settingsThatAllowMemoryMap = new ArrayList<>();
8383
settingsThatAllowMemoryMap.add(Settings.EMPTY);
84-
settingsThatAllowMemoryMap.add(Settings.builder().put("node.store.allow_mmapfs", true).build());
84+
settingsThatAllowMemoryMap.add(Settings.builder().put("node.store.allow_mmap", true).build());
8585

8686
for (final Settings settingThatAllowsMemoryMap : settingsThatAllowMemoryMap) {
8787
assertFailure(check.check(createTestContext(settingThatAllowsMemoryMap, MetaData.EMPTY_META_DATA)));
8888
}
8989
}
9090

9191
public void testMaxMapCountCheckNotEnforcedIfMemoryMapNotAllowed() {
92-
// nothing should happen if current vm.max_map_count is under the limit but mmapfs is not allowed
93-
final Settings settings = Settings.builder().put("node.store.allow_mmapfs", false).build();
92+
// nothing should happen if current vm.max_map_count is under the limit but mmap is not allowed
93+
final Settings settings = Settings.builder().put("node.store.allow_mmap", false).build();
9494
final BootstrapContext context = createTestContext(settings, MetaData.EMPTY_META_DATA);
9595
final BootstrapCheck.BootstrapCheckResult result = check.check(context);
9696
assertTrue(result.isSuccess());

server/src/test/java/org/elasticsearch/index/IndexModuleTests.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,19 +383,20 @@ public void testDisableQueryCacheHasPrecedenceOverForceQueryCache() throws IOExc
383383
indexService.close("simon says", false);
384384
}
385385

386-
public void testMmapfsStoreTypeNotAllowed() {
386+
public void testMmapNotAllowed() {
387+
String storeType = randomFrom(IndexModule.Type.HYBRIDFS.getSettingsKey(), IndexModule.Type.MMAPFS.getSettingsKey());
387388
final Settings settings = Settings.builder()
388389
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
389-
.put("index.store.type", "mmapfs")
390+
.put("index.store.type", storeType)
390391
.build();
391392
final Settings nodeSettings = Settings.builder()
392-
.put(IndexModule.NODE_STORE_ALLOW_MMAPFS.getKey(), false)
393+
.put(IndexModule.NODE_STORE_ALLOW_MMAP.getKey(), false)
393394
.build();
394395
final IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(new Index("foo", "_na_"), settings, nodeSettings);
395396
final IndexModule module =
396397
new IndexModule(indexSettings, emptyAnalysisRegistry, new InternalEngineFactory(), Collections.emptyMap());
397398
final IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> newIndexService(module));
398-
assertThat(e, hasToString(containsString("store type [mmapfs] is not allowed")));
399+
assertThat(e, hasToString(containsString("store type [" + storeType + "] is not allowed")));
399400
}
400401

401402
class CustomQueryCache implements QueryCache {

0 commit comments

Comments
 (0)