Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reject setting index.optimize_auto_generated_id after version 7.0.0 #28895

Merged
merged 8 commits into from
Feb 10, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.lucene.search.ReferenceManager;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.similarities.Similarity;
import org.elasticsearch.Version;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
Expand Down Expand Up @@ -126,6 +127,11 @@ public EngineConfig(ShardId shardId, String allocationId, ThreadPool threadPool,
List<ReferenceManager.RefreshListener> internalRefreshListener, Sort indexSort,
CircuitBreakerService circuitBreakerService, LongSupplier globalCheckpointSupplier,
LongSupplier primaryTermSupplier, TombstoneDocSupplier tombstoneDocSupplier) {
if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is too late to be rejecting this setting. It means the index will already be created and in the cluster state, but all shards will fail during engine creation. The user will be left with a red index.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I moved to createIndexService. Could you please review again?

&& INDEX_OPTIMIZE_AUTO_GENERATED_IDS.exists(indexSettings.getSettings())) {
throw new IllegalArgumentException(
"Setting [" + INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey() + "] was removed in version 7.0.0");
}
this.shardId = shardId;
this.allocationId = allocationId;
this.indexSettings = indexSettings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4975,6 +4975,43 @@ public void testStressUpdateSameDocWhileGettingIt() throws IOException, Interrup
}
}

private EngineConfig createEngineConfigWithSettings(IndexSettings indexSettings) {
return new EngineConfig(shardId, null, threadPool,
indexSettings, null, store, null, null,
null, null, null, null, null,
null, null, null, null, null,
null, null, null, null);
}

public void testOptimizeAutoGeneratedIdsSettingRemoval() throws Exception {
Version version = Version.V_7_0_0;
boolean optimizeAutoGeneratedIds = randomBoolean();
Settings.Builder builder = Settings.builder()
.put(IndexMetaData.SETTING_VERSION_CREATED, version)
.put(EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey(), optimizeAutoGeneratedIds);
IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("index1", builder.build());

IllegalArgumentException exception = expectThrows(IllegalArgumentException.class,
() -> createEngineConfigWithSettings(indexSettings));
assertEquals("Setting [" + EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey() + "] was removed in version 7.0.0",
exception.getMessage());

version = randomFrom(Version.V_6_0_0_rc1, Version.V_6_0_0, Version.V_6_2_0, Version.V_6_3_0);
optimizeAutoGeneratedIds = randomBoolean();
builder = Settings.builder()
.put(IndexMetaData.SETTING_VERSION_CREATED, version)
.put(EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS.getKey(), optimizeAutoGeneratedIds);
IndexSettings indexSettings2 = IndexSettingsModule.newIndexSettings("index2", builder.build());
EngineConfig config = createEngineConfigWithSettings(indexSettings2);
assertEquals(optimizeAutoGeneratedIds, config.isAutoGeneratedIDsOptimizationEnabled());

version = Version.V_7_0_0;
builder = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version);
indexSettings2 = IndexSettingsModule.newIndexSettings("index3", builder.build());
config = createEngineConfigWithSettings(indexSettings2);
assertTrue(config.isAutoGeneratedIDsOptimizationEnabled());
}

public void testPruneOnlyDeletesAtMostLocalCheckpoint() throws Exception {
final AtomicLong clock = new AtomicLong(0);
threadPool = spy(threadPool);
Expand Down