Skip to content

Deprecate translog retention settings #51588

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

Merged
merged 2 commits into from
Jan 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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 @@ -43,6 +43,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.99.99"
reason: "translog retention are deprecated in 8.0"
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":

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ static Settings aggregateIndexSettings(ClusterState currentState, CreateIndexClu
throw new IllegalArgumentException("Creating indices with soft-deletes disabled is no longer supported. " +
"Please do not specify a value for setting [index.soft_deletes.enabled].");
}
validateTranslogRetentionSettings(indexSettings);
return indexSettings;
}

Expand Down Expand Up @@ -929,4 +930,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))) {
deprecationLogger.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 @@ -910,6 +911,21 @@ public void testRejectWithSoftDeletesDisabled() {
+ "Please do not specify a value for setting [index.soft_deletes.enabled]."));
}

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, List.of(), Map.of(),
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