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

Remove translog retention settings #51697

Merged
merged 3 commits into from
Jan 31, 2020
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
7 changes: 0 additions & 7 deletions docs/reference/index-modules/history-retention.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ index since it can no longer simply replay the missing history. The expiry time
of a retention lease defaults to `12h` which should be long enough for most
reasonable recovery scenarios.

Soft deletes are enabled by default on indices created in recent versions, but
they can be explicitly enabled or disabled at index creation time. If soft
deletes are disabled then peer recoveries can still sometimes take place by
copying just the missing operations from the translog
<<index-modules-translog-retention,as long as those operations are retained
there>>. {ccr-cap} will not function if soft deletes are disabled.

[float]
=== History retention settings

Expand Down
37 changes: 0 additions & 37 deletions docs/reference/index-modules/translog.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -75,40 +75,3 @@ update, or bulk request. This setting accepts the following parameters:
operations, to prevent recoveries from taking too long. Once the maximum size
has been reached a flush will happen, generating a new Lucene commit point.
Defaults to `512mb`.

[float]
[[index-modules-translog-retention]]
==== Translog retention

deprecated::[7.4.0, translog retention settings are deprecated in favor of
<<index-modules-history-retention,soft deletes>>. These settings are
effectively ignored since 7.4 and will be removed in a future version].

If an index is not using <<index-modules-history-retention,soft deletes>> to
retain historical operations then {es} recovers each replica shard by replaying
operations from the primary's translog. This means it is important for the
primary to preserve extra operations in its translog in case it needs to
rebuild a replica. Moreover it is important for each replica to preserve extra
operations in its translog in case it is promoted to primary and then needs to
rebuild its own replicas in turn. The following settings control how much
translog is retained for peer recoveries.

`index.translog.retention.size`::

This controls the total size of translog files to keep for each shard.
Keeping more translog files increases the chance of performing an operation
based sync when recovering a replica. If the translog files are not
sufficient, replica recovery will fall back to a file based sync. Defaults to
`512mb`. This setting is ignored, and should not be set, if soft deletes are
enabled. Soft deletes are enabled by default in indices created in {es}
versions 7.0.0 and later.

`index.translog.retention.age`::

This controls the maximum duration for which translog files are kept by each
shard. Keeping more translog files increases the chance of performing an
operation based sync when recovering replicas. If the translog files are not
sufficient, replica recovery will fall back to a file based sync. Defaults to
`12h`. This setting is ignored, and should not be set, if soft deletes are
enabled. Soft deletes are enabled by default in indices created in {es}
versions 7.0.0 and later.
3 changes: 1 addition & 2 deletions docs/reference/indices/flush.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ unflushed transaction log against the cost of performing each flush.

Once each operation has been flushed it is permanently stored in the Lucene
index. This may mean that there is no need to maintain an additional copy of it
in the transaction log, unless <<index-modules-translog-retention,it is retained
for some other reason>>. The transaction log is made up of multiple files,
in the transaction log. The transaction log is made up of multiple files,
called _generations_, and {es} will delete any generation files once they are no
longer needed, freeing up disk space.

Expand Down
8 changes: 8 additions & 0 deletions docs/reference/migration/migrate_8_0/indices.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,11 @@ Creating indices with soft deletes disabled was deprecated in 7.6 and
is no longer supported in 8.0. The setting index.soft_deletes.enabled
can no longer be set to false. As the setting defaults to true, simply
leave the setting unset.

[float]
==== Translog retention settings are no longer supported

Translog retention settings `index.translog.retention.size` and
`index.translog.retention.age` were effectively ignored in 7.4,
deprecated in 7.7, and removed in 8.0 in favor of
<<index-modules-history-retention,soft deletes>>.
Original file line number Diff line number Diff line change
Expand Up @@ -44,39 +44,26 @@
- match: { indices.test.primaries.translog.uncommitted_operations: 0 }

---
"Translog retention settings are deprecated":
"Translog retention settings are no long supported":
- skip:
version: " - 7.6.99"
reason: "translog retention settings are deprecated in 7.6"
features: "warnings"
version: " - 7.9.99"
reason: "translog retention settings are no longer supported in 8.0"
- do:
warnings:
- Translog retention settings [index.translog.retention.age] and [index.translog.retention.size]
are deprecated and effectively ignored. They will be removed in a future version.
catch: /illegal_argument_exception/
indices.create:
index: test
body:
settings:
index.translog.retention.size: 128mb
- do:
indices.put_settings:
indices.create:
index: test
body:
index.number_of_replicas: 0
- do:
warnings:
- Translog retention settings [index.translog.retention.age] and [index.translog.retention.size]
are deprecated and effectively ignored. They will be removed in a future version.
catch: /illegal_argument_exception/
indices.put_settings:
index: test
body:
index.translog.retention.age: 1h
- do:
indices.put_settings:
index: test
body:
index.translog.retention.age: null
index.translog.retention.size: null

---
"Translog last modified age stats":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,12 @@ public static int calculateNumRoutingShards(int numShards, Version indexVersionC
}

public static void validateTranslogRetentionSettings(Settings indexSettings) {
if (IndexMetaData.SETTING_INDEX_VERSION_CREATED.get(indexSettings).onOrAfter(Version.V_8_0_0) &&
(IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING.exists(indexSettings)
|| IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.exists(indexSettings))) {
throw new IllegalArgumentException("Translog retention settings [index.translog.retention.age] " +
"and [index.translog.retention.size] are no longer supported. Please do not specify values for these settings");
}
if (IndexSettings.INDEX_SOFT_DELETES_SETTING.get(indexSettings) &&
(IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING.exists(indexSettings)
|| IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.exists(indexSettings))) {
Expand Down
12 changes: 2 additions & 10 deletions server/src/main/java/org/elasticsearch/index/IndexSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public final class IndexSettings {
* Controls how long translog files that are no longer needed for persistence reasons
* will be kept around before being deleted. Keeping more files is useful to increase
* the chance of ops based recoveries for indices with soft-deletes disabled.
* This setting will be ignored if soft-deletes is used in peer recoveries (default in 7.4).
* TODO: Remove this setting in 9.0.
**/
public static final Setting<TimeValue> INDEX_TRANSLOG_RETENTION_AGE_SETTING =
Setting.timeSetting("index.translog.retention.age", settings -> TimeValue.MINUS_ONE,
Expand All @@ -255,19 +255,11 @@ public final class IndexSettings {
* Controls how many translog files that are no longer needed for persistence reasons
* will be kept around before being deleted. Keeping more files is useful to increase
* the chance of ops based recoveries for indices with soft-deletes disabled.
* This setting will be ignored if soft-deletes is used in peer recoveries (default in 7.4).
* TODO: Remove this setting in 9.0.
**/
public static final Setting<ByteSizeValue> INDEX_TRANSLOG_RETENTION_SIZE_SETTING =
Setting.byteSizeSetting("index.translog.retention.size", settings -> "-1", Property.Dynamic, Property.IndexScope);

/**
* Controls the number of translog files that are no longer needed for persistence reasons will be kept around before being deleted.
* This is a safeguard making sure that the translog deletion policy won't keep too many translog files especially when they're small.
* This setting is intentionally not registered, it is only used in tests
**/
public static final Setting<Integer> INDEX_TRANSLOG_RETENTION_TOTAL_FILES_SETTING =
Setting.intSetting("index.translog.retention.total_files", 100, 0, Setting.Property.IndexScope);

/**
* Controls the maximum length of time since a retention lease is created or renewed before it is considered expired.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
import static org.elasticsearch.cluster.metadata.IndexMetaData.INDEX_NUMBER_OF_ROUTING_SHARDS_SETTING;
import static org.elasticsearch.cluster.metadata.IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING;
import static org.elasticsearch.cluster.metadata.IndexMetaData.INDEX_READ_ONLY_BLOCK;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_INDEX_VERSION_CREATED;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
Expand Down Expand Up @@ -951,14 +952,35 @@ public void testRejectWithSoftDeletesDisabled() {
+ "Please do not specify a value for setting [index.soft_deletes.enabled]."));
}

public void testValidateTranslogRetentionSettings() {
public void testRejectTranslogRetentionSettings() {
request = new CreateIndexClusterStateUpdateRequest("create index", "test", "test");
final Settings.Builder settings = Settings.builder();
if (randomBoolean()) {
settings.put(IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING.getKey(), TimeValue.timeValueMillis(between(1, 120)));
} else {
settings.put(IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.getKey(), between(1, 128) + "mb");
}
if (randomBoolean()) {
settings.put(SETTING_INDEX_VERSION_CREATED.getKey(),
VersionUtils.randomVersionBetween(random(), Version.V_8_0_0, Version.CURRENT));
}
request.settings(settings.build());
IllegalArgumentException error = expectThrows(IllegalArgumentException.class,
() -> aggregateIndexSettings(ClusterState.EMPTY_STATE, request, List.of(), Map.of(),
null, Settings.EMPTY, IndexScopedSettings.DEFAULT_SCOPED_SETTINGS));
assertThat(error.getMessage(), equalTo("Translog retention settings [index.translog.retention.age] " +
"and [index.translog.retention.size] are no longer supported. Please do not specify values for these settings"));
}

public void testDeprecateTranslogRetentionSettings() {
request = new CreateIndexClusterStateUpdateRequest("create index", "test", "test");
final Settings.Builder settings = Settings.builder();
if (randomBoolean()) {
settings.put(IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING.getKey(), TimeValue.timeValueMillis(between(1, 120)));
} else {
settings.put(IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.getKey(), between(1, 128) + "mb");
}
settings.put(SETTING_INDEX_VERSION_CREATED.getKey(), VersionUtils.randomPreviousCompatibleVersion(random(), Version.V_8_0_0));
request.settings(settings.build());
aggregateIndexSettings(ClusterState.EMPTY_STATE, request, List.of(), Map.of(),
null, Settings.EMPTY, IndexScopedSettings.DEFAULT_SCOPED_SETTINGS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,6 @@ public void testAsyncTranslogTrimActuallyWorks() throws Exception {
assertTrue(indexService.getTrimTranslogTask().mustReschedule());
client().prepareIndex("test").setId("1").setSource("{\"foo\": \"bar\"}", XContentType.JSON).get();
client().admin().indices().prepareFlush("test").get();
client().admin().indices().prepareUpdateSettings("test")
.setSettings(Settings.builder()
.put(IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.getKey(), -1)
.put(IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING.getKey(), -1))
.get();
IndexShard shard = indexService.getShard(0);
assertBusy(() -> assertThat(IndexShardTestCase.getTranslog(shard).totalOperations(), equalTo(0)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ public List<Setting<?>> getSettings() {
IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING,
IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING,
IndexSettings.FILE_BASED_RECOVERY_THRESHOLD_SETTING,
IndexModule.INDEX_QUERY_CACHE_EVERYTHING_SETTING,
IndexSettings.INDEX_TRANSLOG_RETENTION_TOTAL_FILES_SETTING
IndexModule.INDEX_QUERY_CACHE_EVERYTHING_SETTING
);
}
}