Skip to content

Commit 2aa650c

Browse files
authored
Deprecate translog retention settings (elastic#51588)
This change deprecates the translog retention settings as they are effectively ignored since 7.4. Relates elastic#50775 Relates elastic#45473
1 parent 893d4a2 commit 2aa650c

File tree

5 files changed

+72
-0
lines changed

5 files changed

+72
-0
lines changed

docs/reference/index-modules/translog.asciidoc

+4
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ update, or bulk request. This setting accepts the following parameters:
8080
[[index-modules-translog-retention]]
8181
==== Translog retention
8282

83+
deprecated::[7.4.0, translog retention settings are deprecated in favor of
84+
<<index-modules-history-retention,soft deletes>>. These settings are
85+
effectively ignored since 7.4 and will be removed in a future version].
86+
8387
If an index is not using <<index-modules-history-retention,soft deletes>> to
8488
retain historical operations then {es} recovers each replica shard by replaying
8589
operations from the primary's translog. This means it is important for the

rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/20_translog.yml

+35
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,41 @@
4343
- lt: { indices.test.primaries.translog.uncommitted_size_in_bytes: $creation_size }
4444
- match: { indices.test.primaries.translog.uncommitted_operations: 0 }
4545

46+
---
47+
"Translog retention settings are deprecated":
48+
- skip:
49+
version: " - 7.99.99"
50+
reason: "translog retention settings are deprecated in 8.0"
51+
features: "warnings"
52+
- do:
53+
warnings:
54+
- Translog retention settings [index.translog.retention.age] and [index.translog.retention.size]
55+
are deprecated and effectively ignored. They will be removed in a future version.
56+
indices.create:
57+
index: test
58+
body:
59+
settings:
60+
index.translog.retention.size: 128mb
61+
- do:
62+
indices.put_settings:
63+
index: test
64+
body:
65+
index.number_of_replicas: 0
66+
- do:
67+
warnings:
68+
- Translog retention settings [index.translog.retention.age] and [index.translog.retention.size]
69+
are deprecated and effectively ignored. They will be removed in a future version.
70+
indices.put_settings:
71+
index: test
72+
body:
73+
index.translog.retention.age: 1h
74+
- do:
75+
indices.put_settings:
76+
index: test
77+
body:
78+
index.translog.retention.age: null
79+
index.translog.retention.size: null
80+
4681
---
4782
"Translog last modified age stats":
4883

server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java

+10
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ static Settings aggregateIndexSettings(ClusterState currentState, CreateIndexClu
472472
throw new IllegalArgumentException("Creating indices with soft-deletes disabled is no longer supported. " +
473473
"Please do not specify a value for setting [index.soft_deletes.enabled].");
474474
}
475+
validateTranslogRetentionSettings(indexSettings);
475476
return indexSettings;
476477
}
477478

@@ -929,4 +930,13 @@ public static int calculateNumRoutingShards(int numShards, Version indexVersionC
929930
return numShards;
930931
}
931932
}
933+
934+
public static void validateTranslogRetentionSettings(Settings indexSettings) {
935+
if (IndexSettings.INDEX_SOFT_DELETES_SETTING.get(indexSettings) &&
936+
(IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING.exists(indexSettings)
937+
|| IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.exists(indexSettings))) {
938+
deprecationLogger.deprecatedAndMaybeLog("translog_retention", "Translog retention settings [index.translog.retention.age] "
939+
+ "and [index.translog.retention.size] are deprecated and effectively ignored. They will be removed in a future version.");
940+
}
941+
}
932942
}

server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataUpdateSettingsService.java

+7
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.elasticsearch.common.settings.Setting;
4444
import org.elasticsearch.common.settings.Settings;
4545
import org.elasticsearch.index.Index;
46+
import org.elasticsearch.index.IndexSettings;
4647
import org.elasticsearch.indices.IndicesService;
4748
import org.elasticsearch.threadpool.ThreadPool;
4849

@@ -214,6 +215,12 @@ public ClusterState execute(ClusterState currentState) {
214215
}
215216
}
216217

218+
if (IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING.exists(normalizedSettings) ||
219+
IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.exists(normalizedSettings)) {
220+
for (String index : actualIndices) {
221+
MetaDataCreateIndexService.validateTranslogRetentionSettings(metaDataBuilder.get(index).getSettings());
222+
}
223+
}
217224
// increment settings versions
218225
for (final String index : actualIndices) {
219226
if (same(currentState.metaData().index(index).getSettings(), metaDataBuilder.get(index).getSettings()) == false) {

server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexServiceTests.java

+16
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.elasticsearch.common.settings.IndexScopedSettings;
4747
import org.elasticsearch.common.settings.Setting;
4848
import org.elasticsearch.common.settings.Settings;
49+
import org.elasticsearch.common.unit.TimeValue;
4950
import org.elasticsearch.common.util.BigArrays;
5051
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
5152
import org.elasticsearch.common.xcontent.XContentFactory;
@@ -910,6 +911,21 @@ public void testRejectWithSoftDeletesDisabled() {
910911
+ "Please do not specify a value for setting [index.soft_deletes.enabled]."));
911912
}
912913

914+
public void testValidateTranslogRetentionSettings() {
915+
request = new CreateIndexClusterStateUpdateRequest("create index", "test", "test");
916+
final Settings.Builder settings = Settings.builder();
917+
if (randomBoolean()) {
918+
settings.put(IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING.getKey(), TimeValue.timeValueMillis(between(1, 120)));
919+
} else {
920+
settings.put(IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.getKey(), between(1, 128) + "mb");
921+
}
922+
request.settings(settings.build());
923+
aggregateIndexSettings(ClusterState.EMPTY_STATE, request, List.of(), Map.of(),
924+
null, Settings.EMPTY, IndexScopedSettings.DEFAULT_SCOPED_SETTINGS);
925+
assertWarnings("Translog retention settings [index.translog.retention.age] "
926+
+ "and [index.translog.retention.size] are deprecated and effectively ignored. They will be removed in a future version.");
927+
}
928+
913929
private IndexTemplateMetaData addMatchingTemplate(Consumer<IndexTemplateMetaData.Builder> configurator) {
914930
IndexTemplateMetaData.Builder builder = templateMetaDataBuilder("template1", "te*");
915931
configurator.accept(builder);

0 commit comments

Comments
 (0)