@@ -195,24 +195,6 @@ public final class IndexSettings {
195
195
new ByteSizeValue (Long .MAX_VALUE , ByteSizeUnit .BYTES ),
196
196
Property .Dynamic , Property .IndexScope );
197
197
198
- /**
199
- * Controls how long translog files that are no longer needed for persistence reasons
200
- * will be kept around before being deleted. A longer retention policy is useful to increase
201
- * the chance of ops based recoveries.
202
- **/
203
- public static final Setting <TimeValue > INDEX_TRANSLOG_RETENTION_AGE_SETTING =
204
- Setting .timeSetting ("index.translog.retention.age" , TimeValue .timeValueHours (12 ), TimeValue .timeValueMillis (-1 ),
205
- Property .Dynamic , Property .IndexScope );
206
-
207
- /**
208
- * Controls how many translog files that are no longer needed for persistence reasons
209
- * will be kept around before being deleted. Keeping more files is useful to increase
210
- * the chance of ops based recoveries.
211
- **/
212
- public static final Setting <ByteSizeValue > INDEX_TRANSLOG_RETENTION_SIZE_SETTING =
213
- Setting .byteSizeSetting ("index.translog.retention.size" , new ByteSizeValue (512 , ByteSizeUnit .MB ), Property .Dynamic ,
214
- Property .IndexScope );
215
-
216
198
/**
217
199
* The maximum size of a translog generation. This is independent of the maximum size of
218
200
* translog operations that have not been flushed.
@@ -258,6 +240,27 @@ public final class IndexSettings {
258
240
Setting .longSetting ("index.soft_deletes.retention.operations" , 0 , 0 ,
259
241
Property .IndexScope , Property .Dynamic );
260
242
243
+ /**
244
+ * Controls how long translog files that are no longer needed for persistence reasons
245
+ * will be kept around before being deleted. Keeping more files is useful to increase
246
+ * the chance of ops based recoveries for indices with soft-deletes disabled.
247
+ * This setting will be ignored if soft-deletes is enabled.
248
+ **/
249
+ public static final Setting <TimeValue > INDEX_TRANSLOG_RETENTION_AGE_SETTING =
250
+ Setting .timeSetting ("index.translog.retention.age" ,
251
+ settings -> INDEX_SOFT_DELETES_SETTING .get (settings ) ? TimeValue .MINUS_ONE : TimeValue .timeValueHours (12 ), TimeValue .MINUS_ONE ,
252
+ Property .Dynamic , Property .IndexScope );
253
+
254
+ /**
255
+ * Controls how many translog files that are no longer needed for persistence reasons
256
+ * will be kept around before being deleted. Keeping more files is useful to increase
257
+ * the chance of ops based recoveries for indices with soft-deletes disabled.
258
+ * This setting will be ignored if soft-deletes is enabled.
259
+ **/
260
+ public static final Setting <ByteSizeValue > INDEX_TRANSLOG_RETENTION_SIZE_SETTING =
261
+ Setting .byteSizeSetting ("index.translog.retention.size" , settings -> INDEX_SOFT_DELETES_SETTING .get (settings ) ? "-1" : "512MB" ,
262
+ Property .Dynamic , Property .IndexScope );
263
+
261
264
/**
262
265
* Controls the maximum length of time since a retention lease is created or renewed before it is considered expired.
263
266
*/
@@ -466,8 +469,6 @@ public IndexSettings(final IndexMetaData indexMetaData, final Settings nodeSetti
466
469
syncInterval = INDEX_TRANSLOG_SYNC_INTERVAL_SETTING .get (settings );
467
470
refreshInterval = scopedSettings .get (INDEX_REFRESH_INTERVAL_SETTING );
468
471
flushThresholdSize = scopedSettings .get (INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING );
469
- translogRetentionAge = scopedSettings .get (INDEX_TRANSLOG_RETENTION_AGE_SETTING );
470
- translogRetentionSize = scopedSettings .get (INDEX_TRANSLOG_RETENTION_SIZE_SETTING );
471
472
generationThresholdSize = scopedSettings .get (INDEX_TRANSLOG_GENERATION_THRESHOLD_SIZE_SETTING );
472
473
mergeSchedulerConfig = new MergeSchedulerConfig (this );
473
474
gcDeletesInMillis = scopedSettings .get (INDEX_GC_DELETES_SETTING ).getMillis ();
@@ -493,6 +494,8 @@ public IndexSettings(final IndexMetaData indexMetaData, final Settings nodeSetti
493
494
this .indexSortConfig = new IndexSortConfig (this );
494
495
searchIdleAfter = scopedSettings .get (INDEX_SEARCH_IDLE_AFTER );
495
496
defaultPipeline = scopedSettings .get (DEFAULT_PIPELINE );
497
+ setTranslogRetentionAge (scopedSettings .get (INDEX_TRANSLOG_RETENTION_AGE_SETTING ));
498
+ setTranslogRetentionSize (scopedSettings .get (INDEX_TRANSLOG_RETENTION_SIZE_SETTING ));
496
499
497
500
scopedSettings .addSettingsUpdateConsumer (MergePolicyConfig .INDEX_COMPOUND_FORMAT_SETTING , mergePolicyConfig ::setNoCFSRatio );
498
501
scopedSettings .addSettingsUpdateConsumer (MergePolicyConfig .INDEX_MERGE_POLICY_DELETES_PCT_ALLOWED_SETTING ,
@@ -553,11 +556,21 @@ private void setTranslogFlushThresholdSize(ByteSizeValue byteSizeValue) {
553
556
}
554
557
555
558
private void setTranslogRetentionSize (ByteSizeValue byteSizeValue ) {
556
- this .translogRetentionSize = byteSizeValue ;
559
+ if (softDeleteEnabled && byteSizeValue .getBytes () >= 0 ) {
560
+ // ignore the translog retention settings if soft-deletes enabled
561
+ this .translogRetentionSize = new ByteSizeValue (-1 );
562
+ } else {
563
+ this .translogRetentionSize = byteSizeValue ;
564
+ }
557
565
}
558
566
559
567
private void setTranslogRetentionAge (TimeValue age ) {
560
- this .translogRetentionAge = age ;
568
+ if (softDeleteEnabled && age .millis () >= 0 ) {
569
+ // ignore the translog retention settings if soft-deletes enabled
570
+ this .translogRetentionAge = TimeValue .MINUS_ONE ;
571
+ } else {
572
+ this .translogRetentionAge = age ;
573
+ }
561
574
}
562
575
563
576
private void setGenerationThresholdSize (final ByteSizeValue generationThresholdSize ) {
@@ -734,13 +747,19 @@ public TimeValue getRefreshInterval() {
734
747
/**
735
748
* Returns the transaction log retention size which controls how much of the translog is kept around to allow for ops based recoveries
736
749
*/
737
- public ByteSizeValue getTranslogRetentionSize () { return translogRetentionSize ; }
750
+ public ByteSizeValue getTranslogRetentionSize () {
751
+ assert softDeleteEnabled == false || translogRetentionSize .getBytes () == -1L : translogRetentionSize ;
752
+ return translogRetentionSize ;
753
+ }
738
754
739
755
/**
740
756
* Returns the transaction log retention age which controls the maximum age (time from creation) that translog files will be kept
741
757
* around
742
758
*/
743
- public TimeValue getTranslogRetentionAge () { return translogRetentionAge ; }
759
+ public TimeValue getTranslogRetentionAge () {
760
+ assert softDeleteEnabled == false || translogRetentionAge .millis () == -1L : translogRetentionSize ;
761
+ return translogRetentionAge ;
762
+ }
744
763
745
764
/**
746
765
* Returns the generation threshold size. As sequence numbers can cause multiple generations to
0 commit comments