Skip to content

Commit

Permalink
Deprecate translog retention settings (#51588) (#51638)
Browse files Browse the repository at this point in the history
This change deprecates the translog retention settings as they are
effectively ignored since 7.4.

Relates #50775
Relates #45473
  • Loading branch information
dnhatn committed Jan 30, 2020
1 parent 1064009 commit f0fad5b
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/reference/index-modules/translog.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ update, or bulk request. This setting accepts the following parameters:
[[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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,41 @@
- lt: { indices.test.primaries.translog.uncommitted_size_in_bytes: $creation_size }
- match: { indices.test.primaries.translog.uncommitted_operations: 0 }

---
"Translog retention settings are deprecated":
- skip:
version: " - 7.6.99"
reason: "translog retention settings are deprecated in 7.6"
features: "warnings"
- 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.
indices.create:
index: test
body:
settings:
index.translog.retention.size: 128mb
- do:
indices.put_settings:
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.
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":
- skip:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ static Settings aggregateIndexSettings(ClusterState currentState, CreateIndexClu
"Creating indices with soft-deletes disabled is deprecated and will be removed in future Elasticsearch versions. " +
"Please do not specify value for setting [index.soft_deletes.enabled] of index [" + request.index() + "].");
}
validateTranslogRetentionSettings(indexSettings);
return indexSettings;
}

Expand Down Expand Up @@ -975,4 +976,13 @@ public static int calculateNumRoutingShards(int numShards, Version indexVersionC
return numShards;
}
}

public static void validateTranslogRetentionSettings(Settings indexSettings) {
if (IndexSettings.INDEX_SOFT_DELETES_SETTING.get(indexSettings) &&
(IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING.exists(indexSettings)
|| IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.exists(indexSettings))) {
DEPRECATION_LOGGER.deprecatedAndMaybeLog("translog_retention", "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.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.threadpool.ThreadPool;

Expand Down Expand Up @@ -214,6 +215,12 @@ public ClusterState execute(ClusterState currentState) {
}
}

if (IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING.exists(normalizedSettings) ||
IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.exists(normalizedSettings)) {
for (String index : actualIndices) {
MetaDataCreateIndexService.validateTranslogRetentionSettings(metaDataBuilder.get(index).getSettings());
}
}
// increment settings versions
for (final String index : actualIndices) {
if (same(currentState.metaData().index(index).getSettings(), metaDataBuilder.get(index).getSettings()) == false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.elasticsearch.common.settings.IndexScopedSettings;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.common.xcontent.XContentFactory;
Expand Down Expand Up @@ -946,6 +947,21 @@ public void testSoftDeletesDisabledDeprecation() {
null, Settings.EMPTY, IndexScopedSettings.DEFAULT_SCOPED_SETTINGS);
}

public void testValidateTranslogRetentionSettings() {
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");
}
request.settings(settings.build());
aggregateIndexSettings(ClusterState.EMPTY_STATE, request, Collections.emptyList(), Collections.emptyMap(),
null, Settings.EMPTY, IndexScopedSettings.DEFAULT_SCOPED_SETTINGS);
assertWarnings("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.");
}

private IndexTemplateMetaData addMatchingTemplate(Consumer<IndexTemplateMetaData.Builder> configurator) {
IndexTemplateMetaData.Builder builder = templateMetaDataBuilder("template1", "te*");
configurator.accept(builder);
Expand Down

0 comments on commit f0fad5b

Please sign in to comment.