@@ -195,24 +195,6 @@ public final class IndexSettings {
195195 new ByteSizeValue (Long .MAX_VALUE , ByteSizeUnit .BYTES ),
196196 Property .Dynamic , Property .IndexScope );
197197
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-
216198 /**
217199 * The maximum size of a translog generation. This is independent of the maximum size of
218200 * translog operations that have not been flushed.
@@ -258,6 +240,27 @@ public final class IndexSettings {
258240 Setting .longSetting ("index.soft_deletes.retention.operations" , 0 , 0 ,
259241 Property .IndexScope , Property .Dynamic );
260242
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+
261264 /**
262265 * Controls the maximum length of time since a retention lease is created or renewed before it is considered expired.
263266 */
@@ -466,8 +469,6 @@ public IndexSettings(final IndexMetaData indexMetaData, final Settings nodeSetti
466469 syncInterval = INDEX_TRANSLOG_SYNC_INTERVAL_SETTING .get (settings );
467470 refreshInterval = scopedSettings .get (INDEX_REFRESH_INTERVAL_SETTING );
468471 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 );
471472 generationThresholdSize = scopedSettings .get (INDEX_TRANSLOG_GENERATION_THRESHOLD_SIZE_SETTING );
472473 mergeSchedulerConfig = new MergeSchedulerConfig (this );
473474 gcDeletesInMillis = scopedSettings .get (INDEX_GC_DELETES_SETTING ).getMillis ();
@@ -493,6 +494,8 @@ public IndexSettings(final IndexMetaData indexMetaData, final Settings nodeSetti
493494 this .indexSortConfig = new IndexSortConfig (this );
494495 searchIdleAfter = scopedSettings .get (INDEX_SEARCH_IDLE_AFTER );
495496 defaultPipeline = scopedSettings .get (DEFAULT_PIPELINE );
497+ setTranslogRetentionAge (scopedSettings .get (INDEX_TRANSLOG_RETENTION_AGE_SETTING ));
498+ setTranslogRetentionSize (scopedSettings .get (INDEX_TRANSLOG_RETENTION_SIZE_SETTING ));
496499
497500 scopedSettings .addSettingsUpdateConsumer (MergePolicyConfig .INDEX_COMPOUND_FORMAT_SETTING , mergePolicyConfig ::setNoCFSRatio );
498501 scopedSettings .addSettingsUpdateConsumer (MergePolicyConfig .INDEX_MERGE_POLICY_DELETES_PCT_ALLOWED_SETTING ,
@@ -553,11 +556,21 @@ private void setTranslogFlushThresholdSize(ByteSizeValue byteSizeValue) {
553556 }
554557
555558 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+ }
557565 }
558566
559567 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+ }
561574 }
562575
563576 private void setGenerationThresholdSize (final ByteSizeValue generationThresholdSize ) {
@@ -734,13 +747,19 @@ public TimeValue getRefreshInterval() {
734747 /**
735748 * Returns the transaction log retention size which controls how much of the translog is kept around to allow for ops based recoveries
736749 */
737- public ByteSizeValue getTranslogRetentionSize () { return translogRetentionSize ; }
750+ public ByteSizeValue getTranslogRetentionSize () {
751+ assert softDeleteEnabled == false || translogRetentionSize .getBytes () == -1L : translogRetentionSize ;
752+ return translogRetentionSize ;
753+ }
738754
739755 /**
740756 * Returns the transaction log retention age which controls the maximum age (time from creation) that translog files will be kept
741757 * around
742758 */
743- public TimeValue getTranslogRetentionAge () { return translogRetentionAge ; }
759+ public TimeValue getTranslogRetentionAge () {
760+ assert softDeleteEnabled == false || translogRetentionAge .millis () == -1L : translogRetentionSize ;
761+ return translogRetentionAge ;
762+ }
744763
745764 /**
746765 * Returns the generation threshold size. As sequence numbers can cause multiple generations to
0 commit comments