Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -30,7 +30,6 @@
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.engine.EngineTestCase;
import org.elasticsearch.index.engine.ReadOnlyEngine;
Expand Down Expand Up @@ -170,10 +169,7 @@ protected void mountSnapshot(
repositoryName,
snapshotName,
indexName,
Settings.builder()
.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), Boolean.FALSE.toString())
.put(restoredIndexSettings)
.build(),
restoredIndexSettings,
Strings.EMPTY_ARRAY,
true,
storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.elasticsearch.cluster.routing.UnassignedInfo;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.snapshots.SnapshotInfo;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.InternalTestCluster;
Expand Down Expand Up @@ -63,7 +62,6 @@ public void testRepositoriesServiceClusterStateApplierIsCalledBeforeIndicesClust

Settings.Builder indexSettingsBuilder = Settings.builder()
.put(SearchableSnapshots.SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), false)
.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), Boolean.FALSE.toString())
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0);

final MountSearchableSnapshotRequest req = new MountSearchableSnapshotRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ public void testCreateAndRestorePartialSearchableSnapshot() throws Exception {

// Peer recovery always copies .liv files but we do not permit writing to searchable snapshot directories so this doesn't work, but
// we can bypass this by forcing soft deletes to be used. TODO this restriction can be lifted when #55142 is resolved.
assertAcked(prepareCreate(indexName, Settings.builder().put(INDEX_SOFT_DELETES_SETTING.getKey(), true)));
final Settings.Builder originalIndexSettings = Settings.builder().put(INDEX_SOFT_DELETES_SETTING.getKey(), true);
if (randomBoolean()) {
originalIndexSettings.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), randomFrom("false", "true", "checksum"));
}
assertAcked(prepareCreate(indexName, originalIndexSettings));
assertAcked(client().admin().indices().prepareAliases().addAlias(indexName, aliasName));

populateIndex(indexName, 10_000);
Expand Down Expand Up @@ -141,9 +145,7 @@ public void testCreateAndRestorePartialSearchableSnapshot() throws Exception {

logger.info("--> restoring partial index [{}] with cache enabled", restoredIndexName);

Settings.Builder indexSettingsBuilder = Settings.builder()
.put(SearchableSnapshots.SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), true)
.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), Boolean.FALSE.toString());
Settings.Builder indexSettingsBuilder = Settings.builder().put(SearchableSnapshots.SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), true);
final List<String> nonCachedExtensions;
if (randomBoolean()) {
nonCachedExtensions = randomSubsetOf(Arrays.asList("fdt", "fdx", "nvd", "dvd", "tip", "cfs", "dim"));
Expand All @@ -164,6 +166,13 @@ public void testCreateAndRestorePartialSearchableSnapshot() throws Exception {
} else {
expectedReplicas = 0;
}
final String indexCheckOnStartup;
if (randomBoolean()) {
indexCheckOnStartup = randomFrom("false", "true", "checksum");
indexSettingsBuilder.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), indexCheckOnStartup);
} else {
indexCheckOnStartup = "false";
}
final String expectedDataTiersPreference;
expectedDataTiersPreference = getDataTiersPreference(MountSearchableSnapshotRequest.Storage.SHARED_CACHE);

Expand Down Expand Up @@ -282,6 +291,7 @@ public void testCreateAndRestorePartialSearchableSnapshot() throws Exception {
assertThat(DataTierAllocationDecider.INDEX_ROUTING_PREFER_SETTING.get(settings), equalTo(expectedDataTiersPreference));
assertTrue(SearchableSnapshotsConstants.SNAPSHOT_PARTIAL_SETTING.get(settings));
assertTrue(DiskThresholdDecider.SETTING_IGNORE_DISK_WATERMARKS.get(settings));
assertThat(IndexSettings.INDEX_CHECK_ON_STARTUP.get(settings), equalTo("false"));

checkSoftDeletesNotEagerlyLoaded(restoredIndexName);
assertTotalHits(restoredIndexName, originalAllHits, originalBarHits);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.mapper.DateFieldMapper;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.shard.IndexLongFieldRange;
Expand Down Expand Up @@ -125,7 +124,6 @@ public void testSearchableSnapshotShardsAreSkippedWithoutQueryingAnyNodeWhenThey

// Force the searchable snapshot to be allocated in a particular node
Settings restoredIndexSettings = Settings.builder()
.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), Boolean.FALSE.toString())
.put(INDEX_ROUTING_REQUIRE_GROUP_SETTING.getConcreteSettingForNamespace("_name").getKey(), dataNodeHoldingSearchableSnapshot)
.build();

Expand Down Expand Up @@ -260,7 +258,6 @@ public void testQueryPhaseIsExecutedInAnAvailableNodeWhenAllShardsCanBeSkipped()

// Force the searchable snapshot to be allocated in a particular node
Settings restoredIndexSettings = Settings.builder()
.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), Boolean.FALSE.toString())
.put(INDEX_ROUTING_REQUIRE_GROUP_SETTING.getConcreteSettingForNamespace("_name").getKey(), dataNodeHoldingSearchableSnapshot)
.build();

Expand Down Expand Up @@ -373,7 +370,6 @@ public void testSearchableSnapshotShardsThatHaveMatchingDataAreNotSkippedOnTheCo

// Force the searchable snapshot to be allocated in a particular node
Settings restoredIndexSettings = Settings.builder()
.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), Boolean.FALSE.toString())
.put(INDEX_ROUTING_REQUIRE_GROUP_SETTING.getConcreteSettingForNamespace("_name").getKey(), dataNodeHoldingSearchableSnapshot)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ public void testCreateAndRestoreSearchableSnapshot() throws Exception {

// Peer recovery always copies .liv files but we do not permit writing to searchable snapshot directories so this doesn't work, but
// we can bypass this by forcing soft deletes to be used. TODO this restriction can be lifted when #55142 is resolved.
assertAcked(prepareCreate(indexName, Settings.builder().put(INDEX_SOFT_DELETES_SETTING.getKey(), true)));
final Settings.Builder originalIndexSettings = Settings.builder().put(INDEX_SOFT_DELETES_SETTING.getKey(), true);
if (randomBoolean()) {
originalIndexSettings.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), randomFrom("false", "true", "checksum"));
}
assertAcked(prepareCreate(indexName, originalIndexSettings));
assertAcked(client().admin().indices().prepareAliases().addAlias(indexName, aliasName));

populateIndex(indexName, 10_000);
Expand Down Expand Up @@ -166,8 +170,7 @@ public void testCreateAndRestoreSearchableSnapshot() throws Exception {
logger.info("--> restoring index [{}] with cache [{}]", restoredIndexName, cacheEnabled ? "enabled" : "disabled");

Settings.Builder indexSettingsBuilder = Settings.builder()
.put(SearchableSnapshots.SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), cacheEnabled)
.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), Boolean.FALSE.toString());
.put(SearchableSnapshots.SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), cacheEnabled);
boolean preWarmEnabled = false;
if (cacheEnabled) {
preWarmEnabled = randomBoolean();
Expand Down Expand Up @@ -246,6 +249,7 @@ public void testCreateAndRestoreSearchableSnapshot() throws Exception {
assertThat(IndexMetadata.INDEX_AUTO_EXPAND_REPLICAS_SETTING.get(settings).toString(), equalTo("false"));
assertThat(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.get(settings), equalTo(expectedReplicas));
assertThat(DataTierAllocationDecider.INDEX_ROUTING_PREFER_SETTING.get(settings), equalTo(expectedDataTiersPreference));
assertThat(IndexSettings.INDEX_CHECK_ON_STARTUP.get(settings), equalTo("false"));

checkSoftDeletesNotEagerlyLoaded(restoredIndexName);
assertTotalHits(restoredIndexName, originalAllHits, originalBarHits);
Expand Down Expand Up @@ -430,9 +434,7 @@ public void testCanMountSnapshotTakenWhileConcurrentlyIndexing() throws Exceptio

logger.info("--> restoring index [{}]", restoredIndexName);

Settings.Builder indexSettingsBuilder = Settings.builder()
.put(SearchableSnapshots.SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), true)
.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), Boolean.FALSE.toString());
Settings.Builder indexSettingsBuilder = Settings.builder().put(SearchableSnapshots.SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), true);
final MountSearchableSnapshotRequest req = new MountSearchableSnapshotRequest(
restoredIndexName,
fsRepoName,
Expand Down Expand Up @@ -494,7 +496,7 @@ public void testMaxRestoreBytesPerSecIsUsed() throws Exception {
repositoryName,
snapshotName,
indexName,
Settings.builder().put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), Boolean.FALSE.toString()).build(),
Settings.EMPTY,
Strings.EMPTY_ARRAY,
true,
MountSearchableSnapshotRequest.Storage.FULL_COPY
Expand Down Expand Up @@ -567,8 +569,7 @@ public void testMountedSnapshotHasNoReplicasByDefault() throws Exception {
{
logger.info("--> restoring index [{}] with default replica counts", restoredIndexName);
Settings.Builder indexSettingsBuilder = Settings.builder()
.put(SearchableSnapshots.SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), true)
.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), Boolean.FALSE.toString());
.put(SearchableSnapshots.SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), true);
final MountSearchableSnapshotRequest req = new MountSearchableSnapshotRequest(
restoredIndexName,
fsRepoName,
Expand Down Expand Up @@ -602,7 +603,6 @@ public void testMountedSnapshotHasNoReplicasByDefault() throws Exception {
logger.info("--> restoring index [{}] with specific replica count", restoredIndexName);
Settings.Builder indexSettingsBuilder = Settings.builder()
.put(SearchableSnapshots.SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), true)
.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), Boolean.FALSE.toString())
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, replicaCount);
final MountSearchableSnapshotRequest req = new MountSearchableSnapshotRequest(
restoredIndexName,
Expand Down Expand Up @@ -636,7 +636,6 @@ public void testMountedSnapshotHasNoReplicasByDefault() throws Exception {
logger.info("--> restoring index [{}] with auto-expand replicas configured", restoredIndexName);
Settings.Builder indexSettingsBuilder = Settings.builder()
.put(SearchableSnapshots.SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), true)
.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), Boolean.FALSE.toString())
.put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, replicaLimit == dataNodesCount ? "0-all" : "0-" + replicaLimit);
final MountSearchableSnapshotRequest req = new MountSearchableSnapshotRequest(
restoredIndexName,
Expand Down Expand Up @@ -1094,6 +1093,62 @@ public void testSnapshotOfSearchableSnapshotCanBeRestoredBeforeRepositoryRegiste
assertTotalHits(restoredIndexName, originalAllHits, originalBarHits);
}

public void testCheckOnStartupCanBeOverridden() throws Exception {
final String suffix = getTestName().toLowerCase(Locale.ROOT);

final String index = "index_" + suffix;
final Settings.Builder indexSettings = Settings.builder();
indexSettings.put(INDEX_SOFT_DELETES_SETTING.getKey(), true);

final String checkOnStartup = randomFrom("false", "true", "checksum", null);
if (checkOnStartup != null) {
indexSettings.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), checkOnStartup);
}
createAndPopulateIndex(index, indexSettings);

final String repository = "repository_" + suffix;
createRepository(repository, "fs");

final String snapshot = "snapshot_" + suffix;
createFullSnapshot(repository, snapshot);
assertAcked(client().admin().indices().prepareDelete(index));

{
final String mountedIndex = mountSnapshot(repository, snapshot, index, Settings.EMPTY);
assertThat(
client().admin()
.indices()
.prepareGetSettings(mountedIndex)
.get()
.getIndexToSettings()
.get(mountedIndex)
.get(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey()),
equalTo("false")
);
assertAcked(client().admin().indices().prepareDelete(mountedIndex));
}
{
final String overridingCheckOnStartup = randomValueOtherThan(checkOnStartup, () -> randomFrom("false", "true", "checksum"));
final String mountedIndex = mountSnapshot(
repository,
snapshot,
index,
Settings.builder().put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), overridingCheckOnStartup).build()
);
assertThat(
client().admin()
.indices()
.prepareGetSettings(mountedIndex)
.get()
.getIndexToSettings()
.get(mountedIndex)
.get(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey()),
equalTo(overridingCheckOnStartup)
);
assertAcked(client().admin().indices().prepareDelete(mountedIndex));
}
}

private void assertSearchableSnapshotStats(String indexName, boolean cacheEnabled, List<String> nonCachedExtensions) {
final SearchableSnapshotsStatsResponse statsResponse = client().execute(
SearchableSnapshotsStatsAction.INSTANCE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.license.DeleteLicenseAction;
import org.elasticsearch.license.License;
import org.elasticsearch.license.LicensesMetadata;
Expand Down Expand Up @@ -71,13 +70,12 @@ public void createAndMountSearchableSnapshot() throws Exception {

assertAcked(client().admin().indices().prepareDelete(indexName));

final Settings.Builder indexSettingsBuilder = Settings.builder().put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), false);
final MountSearchableSnapshotRequest req = new MountSearchableSnapshotRequest(
indexName,
repoName,
snapshotName,
indexName,
indexSettingsBuilder.build(),
Settings.EMPTY,
Strings.EMPTY_ARRAY,
true,
randomFrom(MountSearchableSnapshotRequest.Storage.values())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotAction;
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotRequest;
Expand All @@ -36,13 +35,12 @@ public void createAndMountSearchableSnapshot() throws Exception {

assertAcked(client().admin().indices().prepareDelete(indexName));

final Settings.Builder indexSettingsBuilder = Settings.builder().put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), false);
final MountSearchableSnapshotRequest req = new MountSearchableSnapshotRequest(
indexName,
repoName,
snapshotName,
indexName,
indexSettingsBuilder.build(),
Settings.EMPTY,
Strings.EMPTY_ARRAY,
true,
randomFrom(MountSearchableSnapshotRequest.Storage.values())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotAction;
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotRequest;
Expand Down Expand Up @@ -60,7 +59,6 @@ private MountSearchableSnapshotRequest prepareMountRequest(

final Settings.Builder indexSettingsBuilder = Settings.builder()
.put(SearchableSnapshots.SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), true)
.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), Boolean.FALSE.toString())
.put(mountedIndexSettings.build());

return new MountSearchableSnapshotRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.elasticsearch.common.util.CollectionUtils;
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.transport.MockTransportService;
import org.elasticsearch.transport.TransportService;
Expand Down Expand Up @@ -88,8 +87,7 @@ private MountSearchableSnapshotRequest prepareMountRequest() throws InterruptedE
assertAcked(client().admin().indices().prepareDelete(indexName));

final Settings.Builder indexSettingsBuilder = Settings.builder()
.put(SearchableSnapshots.SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), true)
.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), Boolean.FALSE.toString());
.put(SearchableSnapshots.SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), true);

return new MountSearchableSnapshotRequest(
indexName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ListenableFuture;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.indices.ShardLimitValidator;
import org.elasticsearch.indices.SystemIndices;
import org.elasticsearch.license.XPackLicenseState;
Expand Down Expand Up @@ -228,9 +229,10 @@ protected void masterOperation(
}
}

Settings indexSettings = Settings.builder()
final Settings indexSettings = Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) // can be overridden
.put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, false) // can be overridden
.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), false) // can be overridden
.put(DataTierAllocationDecider.INDEX_ROUTING_PREFER, getDataTiersPreference(request.storage()))
.put(request.indexSettings())
.put(
Expand Down