From 5a58c9e16a4f00a2d0857401ec6efa4d643d03e7 Mon Sep 17 00:00:00 2001 From: Like Date: Sun, 17 Feb 2019 02:34:11 +0800 Subject: [PATCH] Remove setting index.optimize_auto_generated_id (#27600) --- .../common/settings/IndexScopedSettings.java | 1 - .../index/engine/EngineConfig.java | 18 -------- .../index/engine/InternalEngine.java | 9 ---- .../elasticsearch/indices/IndicesService.java | 6 --- .../indices/IndicesServiceTests.java | 44 ------------------- .../TransportResumeFollowActionTests.java | 2 - 6 files changed, 80 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java b/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java index 1d2e54ae86d7c..9d936a28846e4 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java +++ b/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java @@ -159,7 +159,6 @@ public final class IndexScopedSettings extends AbstractScopedSettings { IndexModule.INDEX_QUERY_CACHE_ENABLED_SETTING, FsDirectoryService.INDEX_LOCK_FACTOR_SETTING, EngineConfig.INDEX_CODEC_SETTING, - EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS, IndexMetaData.SETTING_WAIT_FOR_ACTIVE_SHARDS, IndexSettings.DEFAULT_PIPELINE, diff --git a/server/src/main/java/org/elasticsearch/index/engine/EngineConfig.java b/server/src/main/java/org/elasticsearch/index/engine/EngineConfig.java index 7716cf93ffd6b..7696d545649d5 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/EngineConfig.java +++ b/server/src/main/java/org/elasticsearch/index/engine/EngineConfig.java @@ -116,16 +116,6 @@ public Supplier retentionLeasesSupplier() { } }, Property.IndexScope, Property.NodeScope); - /** - * Configures an index to optimize documents with auto generated ids for append only. If this setting is updated from false - * to true might not take effect immediately. In other words, disabling the optimization will be immediately applied while - * re-enabling it might not be applied until the engine is in a safe state to do so. Depending on the engine implementation a change to - * this setting won't be reflected re-enabled optimization until the engine is restarted or the index is closed and reopened. - * The default is true - */ - public static final Setting INDEX_OPTIMIZE_AUTO_GENERATED_IDS = Setting.boolSetting("index.optimize_auto_generated_id", true, - Property.IndexScope, Property.Dynamic); - private final TranslogConfig translogConfig; /** @@ -349,14 +339,6 @@ public List getExternalRefreshListener() { */ public List getInternalRefreshListener() { return internalRefreshListener;} - - /** - * returns true if the engine is allowed to optimize indexing operations with an auto-generated ID - */ - public boolean isAutoGeneratedIDsOptimizationEnabled() { - return indexSettings.getValue(INDEX_OPTIMIZE_AUTO_GENERATED_IDS); - } - /** * Return the sort order of this index, or null if the index has no sort. */ diff --git a/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java b/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java index 7ddd6348f5245..2def84f875b17 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java +++ b/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java @@ -171,9 +171,6 @@ public InternalEngine(EngineConfig engineConfig) { final EngineConfig engineConfig, final BiFunction localCheckpointTrackerSupplier) { super(engineConfig); - if (engineConfig.isAutoGeneratedIDsOptimizationEnabled() == false) { - updateAutoIdTimestamp(Long.MAX_VALUE, true); - } final TranslogDeletionPolicy translogDeletionPolicy = new TranslogDeletionPolicy( engineConfig.getIndexSettings().getTranslogRetentionSize().getBytes(), engineConfig.getIndexSettings().getTranslogRetentionAge().getMillis() @@ -2400,12 +2397,6 @@ public void onSettingsChanged() { mergeScheduler.refreshConfig(); // config().isEnableGcDeletes() or config.getGcDeletesInMillis() may have changed: maybePruneDeletes(); - if (engineConfig.isAutoGeneratedIDsOptimizationEnabled() == false) { - // this is an anti-viral settings you can only opt out for the entire index - // only if a shard starts up again due to relocation or if the index is closed - // the setting will be re-interpreted if it's set to true - updateAutoIdTimestamp(Long.MAX_VALUE, true); - } final TranslogDeletionPolicy translogDeletionPolicy = translog.getDeletionPolicy(); final IndexSettings indexSettings = engineConfig.getIndexSettings(); translogDeletionPolicy.setRetentionAgeInMillis(indexSettings.getTranslogRetentionAge().getMillis()); diff --git a/server/src/main/java/org/elasticsearch/indices/IndicesService.java b/server/src/main/java/org/elasticsearch/indices/IndicesService.java index 6bacc17b2886d..0c076bb66b190 100644 --- a/server/src/main/java/org/elasticsearch/indices/IndicesService.java +++ b/server/src/main/java/org/elasticsearch/indices/IndicesService.java @@ -83,7 +83,6 @@ import org.elasticsearch.index.analysis.AnalysisRegistry; import org.elasticsearch.index.cache.request.ShardRequestCache; import org.elasticsearch.index.engine.CommitStats; -import org.elasticsearch.index.engine.EngineConfig; import org.elasticsearch.index.engine.EngineFactory; import org.elasticsearch.index.engine.InternalEngineFactory; import org.elasticsearch.index.fielddata.IndexFieldDataCache; @@ -494,11 +493,6 @@ private synchronized IndexService createIndexService(final String reason, List builtInListeners, IndexingOperationListener... indexingOperationListeners) throws IOException { final IndexSettings idxSettings = new IndexSettings(indexMetaData, settings, indexScopedSettings); - if (idxSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0) - && EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.exists(idxSettings.getSettings())) { - throw new IllegalArgumentException( - "Setting [" + EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey() + "] was removed in version 7.0.0"); - } // we ignore private settings since they are not registered settings indexScopedSettings.validate(indexMetaData.getSettings(), true, true, true); logger.debug("creating Index [{}], shards [{}]/[{}] - reason [{}]", diff --git a/server/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java b/server/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java index aa38f9782f006..a8ae4bd11f61b 100644 --- a/server/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java +++ b/server/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java @@ -642,48 +642,4 @@ public static ClusterState createClusterForShardLimitTest(int nodesInCluster, in .build(); } - public void testOptimizeAutoGeneratedIdsSettingRemoval() throws Exception { - final IndicesService indicesService = getIndicesService(); - - final Index index = new Index("foo-index", UUIDs.randomBase64UUID()); - Settings.Builder builder = Settings.builder() - .put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_7_0_0) - .put(IndexMetaData.SETTING_INDEX_UUID, index.getUUID()); - IndexMetaData indexMetaData = new IndexMetaData.Builder(index.getName()) - .settings(builder.build()) - .numberOfShards(1) - .numberOfReplicas(0) - .build(); - IndexService indexService = indicesService.createIndex(indexMetaData, Collections.emptyList()); - assertNotNull(indexService); - - final Index index2 = new Index("bar-index", UUIDs.randomBase64UUID()); - Settings.Builder builder2 = Settings.builder() - .put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_7_0_0) - .put(IndexMetaData.SETTING_INDEX_UUID, index2.getUUID()) - .put(EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey(), randomBoolean()); - IndexMetaData indexMetaData2 = new IndexMetaData.Builder(index2.getName()) - .settings(builder2.build()) - .numberOfShards(1) - .numberOfReplicas(0) - .build(); - IllegalArgumentException ex = expectThrows(IllegalArgumentException.class, - () -> indicesService.createIndex(indexMetaData2, Collections.emptyList())); - assertEquals("Setting [" + EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey() + "] was removed in version 7.0.0", - ex.getMessage()); - - Version version = randomFrom(Version.V_6_0_0_rc1, Version.V_6_0_0, Version.V_6_2_0, Version.V_6_3_0, Version.V_6_4_0); - builder = Settings.builder() - .put(IndexMetaData.SETTING_VERSION_CREATED, version) - .put(IndexMetaData.SETTING_INDEX_UUID, index2.getUUID()) - .put(EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey(), randomBoolean()); - IndexMetaData indexMetaData3 = new IndexMetaData.Builder(index2.getName()) - .settings(builder.build()) - .numberOfShards(1) - .numberOfReplicas(0) - .build(); - IndexService indexService2 = indicesService.createIndex(indexMetaData3, Collections.emptyList()); - assertNotNull(indexService2); - } - } diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowActionTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowActionTests.java index 57bc30210fa74..ef1fa1a80259e 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowActionTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowActionTests.java @@ -14,7 +14,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.MapperTestUtils; -import org.elasticsearch.index.engine.EngineConfig; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.VersionUtils; @@ -233,7 +232,6 @@ public void testDynamicIndexSettingsAreClassified() { replicatedSettings.add(MapperService.INDEX_MAPPER_DYNAMIC_SETTING); replicatedSettings.add(IndexSettings.MAX_NGRAM_DIFF_SETTING); replicatedSettings.add(IndexSettings.MAX_SHINGLE_DIFF_SETTING); - replicatedSettings.add(EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS); for (Setting setting : IndexScopedSettings.BUILT_IN_INDEX_SETTINGS) { if (setting.isDynamic()) {