diff --git a/docs/reference/index-modules/store.asciidoc b/docs/reference/index-modules/store.asciidoc index a5478a5bc120a..8c1b99a42f2a6 100644 --- a/docs/reference/index-modules/store.asciidoc +++ b/docs/reference/index-modules/store.asciidoc @@ -76,9 +76,9 @@ memory mapped. All other files are opened using Lucene `NIOFSDirectory`. Similarly to `mmapfs` be sure you have allowed plenty of <>. -[[allow-mmapfs]] +[[allow-mmap]] You can restrict the use of the `mmapfs` and the related `hybridfs` store type -via the setting `node.store.allow_mmapfs`. This is a boolean setting indicating +via the setting `node.store.allow_mmap`. This is a boolean setting indicating whether or not memory-mapping is allowed. The default is to allow it. This setting is useful, for example, if you are in an environment where you can not control the ability to create a lot of memory maps so you need disable the diff --git a/docs/reference/migration/migrate_7_0/settings.asciidoc b/docs/reference/migration/migrate_7_0/settings.asciidoc index d983994b0c517..6144888fb545d 100644 --- a/docs/reference/migration/migrate_7_0/settings.asciidoc +++ b/docs/reference/migration/migrate_7_0/settings.asciidoc @@ -36,6 +36,11 @@ of the node id. It can still be configured explicitly in `elasticsearch.yml`. available to keep the display output in APIs as `bulk` instead of `write`. These fallback settings and this system property have been removed. +[float] +==== Disabling memory-mapping + +* The setting `node.store.allow_mmapfs` has been renamed to `node.store.allow_mmap`. + [float] [[remove-http-enabled]] ==== Http enabled setting removed diff --git a/docs/reference/setup/bootstrap-checks.asciidoc b/docs/reference/setup/bootstrap-checks.asciidoc index 34b39546324d1..d9b540d39ceb3 100644 --- a/docs/reference/setup/bootstrap-checks.asciidoc +++ b/docs/reference/setup/bootstrap-checks.asciidoc @@ -157,9 +157,9 @@ and is enforced on Linux only. To pass the maximum map count check, you must configure `vm.max_map_count` via `sysctl` to be at least `262144`. Alternatively, the maximum map count check is only needed if you are using -`mmapfs` as the <> for your indices. If you -<> the use of `mmapfs` then this bootstrap check will -not be enforced. +`mmapfs` or `hybridfs` as the <> for your +indices. If you <> the use of `mmap` then this +bootstrap check will not be enforced. === Client JVM check diff --git a/server/src/main/java/org/elasticsearch/bootstrap/BootstrapChecks.java b/server/src/main/java/org/elasticsearch/bootstrap/BootstrapChecks.java index eb53cbaef70ba..e77568105db7d 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/BootstrapChecks.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/BootstrapChecks.java @@ -407,8 +407,8 @@ static class MaxMapCountCheck implements BootstrapCheck { @Override public BootstrapCheckResult check(final BootstrapContext context) { - // we only enforce the check if mmapfs is an allowed store type - if (IndexModule.NODE_STORE_ALLOW_MMAPFS.get(context.settings())) { + // we only enforce the check if a store is allowed to use mmap at all + if (IndexModule.NODE_STORE_ALLOW_MMAP.get(context.settings())) { if (getMaxMapCount() != -1 && getMaxMapCount() < LIMIT) { final String message = String.format( Locale.ROOT, diff --git a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java index 1e9736bccc81b..573e318abf1ed 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java @@ -284,7 +284,7 @@ public void apply(Settings value, Settings current, Settings previous) { HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_OVERHEAD_SETTING, HierarchyCircuitBreakerService.ACCOUNTING_CIRCUIT_BREAKER_LIMIT_SETTING, HierarchyCircuitBreakerService.ACCOUNTING_CIRCUIT_BREAKER_OVERHEAD_SETTING, - IndexModule.NODE_STORE_ALLOW_MMAPFS, + IndexModule.NODE_STORE_ALLOW_MMAP, ClusterService.CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, ClusterService.USER_DEFINED_META_DATA, SearchService.DEFAULT_SEARCH_TIMEOUT_SETTING, diff --git a/server/src/main/java/org/elasticsearch/index/IndexModule.java b/server/src/main/java/org/elasticsearch/index/IndexModule.java index 288fed89d2ce9..6b83d2252dec7 100644 --- a/server/src/main/java/org/elasticsearch/index/IndexModule.java +++ b/server/src/main/java/org/elasticsearch/index/IndexModule.java @@ -84,7 +84,7 @@ */ public final class IndexModule { - public static final Setting NODE_STORE_ALLOW_MMAPFS = Setting.boolSetting("node.store.allow_mmapfs", true, Property.NodeScope); + public static final Setting NODE_STORE_ALLOW_MMAP = Setting.boolSetting("node.store.allow_mmap", true, Property.NodeScope); public static final Setting INDEX_STORE_TYPE_SETTING = new Setting<>("index.store.type", "", Function.identity(), Property.IndexScope, Property.NodeScope); @@ -355,8 +355,8 @@ public interface IndexSearcherWrapperFactory { IndexSearcherWrapper newWrapper(IndexService indexService); } - public static Type defaultStoreType(final boolean allowMmapfs) { - if (allowMmapfs && Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) { + public static Type defaultStoreType(final boolean allowMmap) { + if (allowMmap && Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) { return Type.HYBRIDFS; } else if (Constants.WINDOWS) { return Type.SIMPLEFS; @@ -406,9 +406,9 @@ private static IndexStore getIndexStore( final IndexSettings indexSettings, final Map> indexStoreFactories) { final String storeType = indexSettings.getValue(INDEX_STORE_TYPE_SETTING); final Type type; - final Boolean allowMmapfs = NODE_STORE_ALLOW_MMAPFS.get(indexSettings.getNodeSettings()); + final Boolean allowMmap = NODE_STORE_ALLOW_MMAP.get(indexSettings.getNodeSettings()); if (storeType.isEmpty() || Type.FS.getSettingsKey().equals(storeType)) { - type = defaultStoreType(allowMmapfs); + type = defaultStoreType(allowMmap); } else { if (isBuiltinType(storeType)) { type = Type.fromSettingsKey(storeType); @@ -416,8 +416,8 @@ private static IndexStore getIndexStore( type = null; } } - if (type != null && type == Type.MMAPFS && allowMmapfs == false) { - throw new IllegalArgumentException("store type [mmapfs] is not allowed"); + if (allowMmap == false && (type == Type.MMAPFS || type == Type.HYBRIDFS)) { + throw new IllegalArgumentException("store type [" + storeType + "] is not allowed because mmap is disabled"); } final IndexStore store; if (storeType.isEmpty() || isBuiltinType(storeType)) { diff --git a/server/src/main/java/org/elasticsearch/index/store/FsDirectoryService.java b/server/src/main/java/org/elasticsearch/index/store/FsDirectoryService.java index 345ef1eef41f6..7e6a440c5257a 100644 --- a/server/src/main/java/org/elasticsearch/index/store/FsDirectoryService.java +++ b/server/src/main/java/org/elasticsearch/index/store/FsDirectoryService.java @@ -88,7 +88,7 @@ protected Directory newFSDirectory(Path location, LockFactory lockFactory) throw indexSettings.getSettings().get(IndexModule.INDEX_STORE_TYPE_SETTING.getKey(), IndexModule.Type.FS.getSettingsKey()); IndexModule.Type type; if (IndexModule.Type.FS.match(storeType)) { - type = IndexModule.defaultStoreType(IndexModule.NODE_STORE_ALLOW_MMAPFS.get(indexSettings.getNodeSettings())); + type = IndexModule.defaultStoreType(IndexModule.NODE_STORE_ALLOW_MMAP.get(indexSettings.getNodeSettings())); } else { type = IndexModule.Type.fromSettingsKey(storeType); } diff --git a/server/src/test/java/org/elasticsearch/bootstrap/MaxMapCountCheckTests.java b/server/src/test/java/org/elasticsearch/bootstrap/MaxMapCountCheckTests.java index b67dd5db18a01..7557c565039c1 100644 --- a/server/src/test/java/org/elasticsearch/bootstrap/MaxMapCountCheckTests.java +++ b/server/src/test/java/org/elasticsearch/bootstrap/MaxMapCountCheckTests.java @@ -76,12 +76,12 @@ public void testMaxMapCountCheckBelowLimitAndMemoryMapAllowed() { /* * There are two ways that memory maps are allowed: * - by default - * - mmapfs is explicitly allowed - * We want to test that if mmapfs is allowed then the max map count check is enforced. + * - mmap is explicitly allowed + * We want to test that if mmap is allowed then the max map count check is enforced. */ final List settingsThatAllowMemoryMap = new ArrayList<>(); settingsThatAllowMemoryMap.add(Settings.EMPTY); - settingsThatAllowMemoryMap.add(Settings.builder().put("node.store.allow_mmapfs", true).build()); + settingsThatAllowMemoryMap.add(Settings.builder().put("node.store.allow_mmap", true).build()); for (final Settings settingThatAllowsMemoryMap : settingsThatAllowMemoryMap) { assertFailure(check.check(createTestContext(settingThatAllowsMemoryMap, MetaData.EMPTY_META_DATA))); @@ -89,8 +89,8 @@ public void testMaxMapCountCheckBelowLimitAndMemoryMapAllowed() { } public void testMaxMapCountCheckNotEnforcedIfMemoryMapNotAllowed() { - // nothing should happen if current vm.max_map_count is under the limit but mmapfs is not allowed - final Settings settings = Settings.builder().put("node.store.allow_mmapfs", false).build(); + // nothing should happen if current vm.max_map_count is under the limit but mmap is not allowed + final Settings settings = Settings.builder().put("node.store.allow_mmap", false).build(); final BootstrapContext context = createTestContext(settings, MetaData.EMPTY_META_DATA); final BootstrapCheck.BootstrapCheckResult result = check.check(context); assertTrue(result.isSuccess()); diff --git a/server/src/test/java/org/elasticsearch/index/IndexModuleTests.java b/server/src/test/java/org/elasticsearch/index/IndexModuleTests.java index df411f81e3c84..5f6659afd7397 100644 --- a/server/src/test/java/org/elasticsearch/index/IndexModuleTests.java +++ b/server/src/test/java/org/elasticsearch/index/IndexModuleTests.java @@ -383,19 +383,20 @@ public void testDisableQueryCacheHasPrecedenceOverForceQueryCache() throws IOExc indexService.close("simon says", false); } - public void testMmapfsStoreTypeNotAllowed() { + public void testMmapNotAllowed() { + String storeType = randomFrom(IndexModule.Type.HYBRIDFS.getSettingsKey(), IndexModule.Type.MMAPFS.getSettingsKey()); final Settings settings = Settings.builder() .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) - .put("index.store.type", "mmapfs") + .put("index.store.type", storeType) .build(); final Settings nodeSettings = Settings.builder() - .put(IndexModule.NODE_STORE_ALLOW_MMAPFS.getKey(), false) + .put(IndexModule.NODE_STORE_ALLOW_MMAP.getKey(), false) .build(); final IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(new Index("foo", "_na_"), settings, nodeSettings); final IndexModule module = new IndexModule(indexSettings, emptyAnalysisRegistry, new InternalEngineFactory(), Collections.emptyMap()); final IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> newIndexService(module)); - assertThat(e, hasToString(containsString("store type [mmapfs] is not allowed"))); + assertThat(e, hasToString(containsString("store type [" + storeType + "] is not allowed"))); } class CustomQueryCache implements QueryCache {