DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
Motivation
The current HistoryServer job history retention mechanism in Flink is limited to a single quantity-based policy, controlled by the configuration parameter: historyserver.archive.retained-jobs
This setting specifies the maximum number of jobs retained per archive directory. Although functional, it does not cover common operational requirements such as time-based retention (e.g., retain only jobs finished within the last X days) or combined policies (e.g., retain jobs no older than 7 days AND no more than 100 jobs).
Operational scenarios often require more flexibility to:
Control storage growth in environments with frequent job completions.
Comply with data retention regulations that mandate deletion after a certain time.
Implement hybrid policies combining time-to-live (TTL) and quantity constraints.
This FLIP proposes composite and configurable job history retention policies in HistoryServer.
Public Interfaces
This will introduce a new configuration parameters.
| Key | Type | Default | Description | Comments/Note |
|---|---|---|---|---|
| historyserver.archive.retained-ttl | Duration | None | The job archived files would be retained within the TTL (Time to Live) period. | When there are multiple history server instances with different configurations, they are working independently today and may have conflict configs. This is an existing problem. |
Proposed Changes
Retention Strategy Abstraction
Introduce the new interface to define whether the target archive files should be retained.
Each retention policy implements this interface to decide whether a given job archive should be retained.
Provided Retention Strategies
a. TimeToLiveJobRetainedStrategy
Uses
ttlthreshold from configuration.Retains jobs whose modification time is within the TTL duration.
b. QuantityJobRetainedStrategy
Uses
quantitythreshold from configuration.This strategy would be used to refactor the original logic of retain strategy that configured from (historyserver.archive.retained-jobs).Retains jobs if their index in the ordered archive list is within the threshold.
c. CompositeJobRetainedStrategy
Combines multiple strategies with a logic AND operator: Retain only if all strategies return
true when the historyserver.archive.retained-ttl and historyserver.archive.retained-jobs are both enabled.
The timing to check whether target files have exceeded the retention thresholds
Just like the implementation in the POC[1], We could follow the process where HistoryServer#start method periodically invokes HistoryServerArchiveFetcher#fetchArchives based on 'historyserver.archive.fs.refresh-interval' to check whether target files should be retained.
Compatibility, Deprecation, and Migration Plan
N.A
Test Plan
Add the corresponding test cases.
The POC draft
POC[1]
Rejected Alternatives
Public Interfaces
This will introduce two new configuration parameters to replace and extend the original setting: historyserver.archive.retained-jobs.
-1 means unlimited. 0 or values less than -1 will throw IllegalConfigurationException. | ||||
| ||||
ttl accepts duration strings (e.g., "7d", "24h"), quantity accepts integers. |
Proposed Changes
Retention Strategy Abstraction
Introduce the new interface to define whether the target archive files should be retained.JobArchivesRetainedStrategy
|
|
Each retention policy implements this interface to decide whether a given job archive should be retained.
Provided Retention Strategies
a. TimeToLiveBasedJobRetainedStrategy
Usesttlthreshold from configuration.Retains jobs whose modification time is within the TTL duration.
b. QuantityBasedJobRetainedStrategy
Usesquantitythreshold from configuration.Retains jobs if their index in the ordered archive list is within the threshold.
c. CompositeBasedJobRetainedStrategy
Combines multiple strategies with a logic operator:OR: Retain if any strategy returnstrue.AND: Retain only if all strategies returntrue.
Allows flexible combinations (TTL and quantity).
Retained Mode Configuration
The historyserver.archive.retained-jobs.mode option determines which composite strategy is created:
TTL strategy only. | |
Quantity strategy only. | |
AND. | |
OR. |
Compatibility, Deprecation, and Migration Plan
Ifhistoryserver.archive.retained-jobs.modeis not set, the old behavior (historyserver.archive.retained-jobs) is used.If set, the new composite strategy logic takes effect.Invalid thresholds (e.g.,quantity = 0or< -1, orttl < 0ms) will triggerIllegalConfigurationException.