Skip to content

[FLINK-37155][historyserver] Decouple remote archive retention from local processing limit - #29008

Open
argoyal2212 wants to merge 2 commits into
apache:masterfrom
argoyal2212:argoyal+01/flink-decouple-remote-retention
Open

[FLINK-37155][historyserver] Decouple remote archive retention from local processing limit#29008
argoyal2212 wants to merge 2 commits into
apache:masterfrom
argoyal2212:argoyal+01/flink-decouple-remote-retention

Conversation

@argoyal2212

Copy link
Copy Markdown
Contributor

What is the purpose of the change

HistoryServerOptions.HISTORY_SERVER_RETAINED_JOBS currently gates both (a) which archives the HistoryServer polls/processes locally, and (b) which archives are deleted from the remote archive directory. This means operators cannot keep a large/unbounded remote job-archive history while only actively refreshing a small recent window locally — trimming the local processing window also deletes the "older" jobs remotely.

This closes that gap, which is what FLIP-505 originally set out to solve, before FLIP-584/585 (FLINK-39911, FLINK-40097) landed a more general pluggable ArchiveStorage backend + on-demand lazy-fetch mechanism that already covers FLIP-505's other goals (per-job on-demand fetch, avoiding local disk/inode exhaustion via a pluggable storage backend). This PR adds the one remaining piece: decoupling remote retention from the local processing limit.

Brief change log

  • Added historyserver.archive.retain-remote-beyond-local-limit (boolean, default false, fully backward compatible).
  • HistoryServerArchiveFetcher.scanArchives(): when enabled, archives beyond historyserver.archive.retained-jobs are cleaned up locally only (new cleanupLocalArchivesBeyondRetainedLimit), leaving the remote archive intact, instead of calling cleanupArchivesBeyondRetainedLimit (which deletes both local and remote).
  • Such archives remain reachable on demand via the existing lazyFetchArchiveProactively path when historyserver.archive.load.mode=LAZY.
  • HistoryServer reads and wires the new option into the job-archive fetcher (applications are unaffected — this only applies to job archives, matching FLIP-505's original scope).
  • Regenerated docs/layouts/shortcodes/generated/history_server_configuration.html.

Verifying this change

This change added tests and can be verified as follows:

  • Added HistoryServerArchiveFetcherTest#testArchivesBeyondRetainedLimitAreDeletedFromRemoteByDefault and #testArchivesBeyondRetainedLimitAreKeptRemotelyWhenConfigured, covering both storage backends (File/RocksDB), asserting: default behavior is unchanged (remote archive deleted beyond limit); with the flag enabled, the remote archive persists, is not locally cached, and is still fetchable on demand.
  • All 24 tests in HistoryServerArchiveFetcherTest pass locally.

Does this pull request potentially affect one of the following parts?

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): yes, one new @PublicEvolving ConfigOption
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? yes
  • If yes, how is the feature documented? JavaDocs + generated configuration docs

@flinkbot

flinkbot commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@argoyal2212
argoyal2212 force-pushed the argoyal+01/flink-decouple-remote-retention branch from 67ac6ed to 5a0f088 Compare August 25, 2026 03:59
@argoyal2212 argoyal2212 changed the title [FLINK-XXXXX][historyserver] Decouple remote archive retention from local processing limit [FLINK-37155][historyserver] Decouple remote archive retention from local processing limit Aug 25, 2026
…ocal processing limit

Adds historyserver.archive.retain-remote-beyond-local-limit (default
false, backward compatible). When enabled, job archives beyond
historyserver.archive.retained-jobs are no longer polled/processed
locally, but are kept in the remote archive directory instead of
being deleted. Such archives remain reachable on demand via the
existing lazyFetchArchiveProactively on-demand fetch path when
historyserver.archive.load.mode is set to LAZY.

This closes a gap left after FLINK-39911/FLINK-40097 introduced the
pluggable ArchiveStorage backend and on-demand lazy archive loading:
retainedStrategy.shouldRetain() still gated both local processing
and remote deletion together, so operators could not keep an
unbounded remote archive history while only actively
polling/caching a small recent window locally.

This addresses the remaining scope of FLIP-505 / FLINK-37155: the
on-demand per-job fetch and recently-viewed-job prioritization goals
of that FLIP are already covered by FLINK-39911/FLINK-40097; this
change covers the remaining decouple-local-vs-remote-retention goal.

- HistoryServerOptions: new HISTORY_SERVER_RETAIN_REMOTE_BEYOND_LOCAL_LIMIT option.
- HistoryServerArchiveFetcher: new constructor overload taking the flag;
  scanArchives() now routes archives beyond the retained limit to a new
  cleanupLocalArchivesBeyondRetainedLimit() (local-only cleanup) instead
  of cleanupArchivesBeyondRetainedLimit() (local+remote) when enabled.
- HistoryServer: reads and wires the new option into the job archive fetcher.
- Regenerated docs/layouts/shortcodes/generated/history_server_configuration.html.
- Added HistoryServerArchiveFetcherTest coverage for both the default
  (remote-deleted) and opted-in (remote-retained, still fetchable
  on-demand) behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@argoyal2212
argoyal2212 force-pushed the argoyal+01/flink-decouple-remote-retention branch from 5a0f088 to 22abdde Compare August 25, 2026 04:10
@RocMarshal
RocMarshal requested a lite review from Copilot August 25, 2026 06:00
@RocMarshal RocMarshal self-assigned this Aug 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR decouples local HistoryServer archive processing limits from remote job-archive retention through an opt-in configuration option.

Changes:

  • Adds historyserver.archive.retain-remote-beyond-local-limit, defaulting to false.
  • Implements local-only cleanup for archives beyond the local limit.
  • Wires the option through HistoryServer.
  • Adds File/RocksDB coverage and regenerates configuration documentation.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Reviewed changes
flink-runtime-web/src/test/java/org/apache/flink/runtime/webmonitor/history/HistoryServerArchiveFetcherTest.java Adds tests for default deletion and configured remote retention behavior.
flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/history/HistoryServerArchiveFetcher.java Implements local-only cleanup. Moderate (4 votes): TTL-expired archives can be incorrectly retained remotely when the local count limit is -1; the local-only path should distinguish count-limit rejection from TTL expiry.
flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/history/HistoryServer.java Reads and wires the new option. Nit (4 votes): Log the effective retention behavior during initialization.
flink-core/src/main/java/org/apache/flink/configuration/HistoryServerOptions.java Defines the new public configuration option.
docs/layouts/shortcodes/generated/history_server_configuration.html Documents the new configuration option.
Suppressed comments (1)

flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/history/HistoryServer.java:295

  • The new tests exercise the fetcher constructor directly, but none instantiate HistoryServer with this option. A regression in this configuration read/pass-through would leave the public option ineffective while all added tests still pass; add a HistoryServer-level test that sets the option and verifies remote retention.
        boolean retainRemoteBeyondLocalLimit =
                config.get(HistoryServerOptions.HISTORY_SERVER_RETAIN_REMOTE_BEYOND_LOCAL_LIMIT);

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions github-actions Bot added the community-reviewed PR has been reviewed by the community. label Aug 25, 2026
TTL-expired archives are now always deleted remotely regardless of retainRemoteBeyondLocalLimit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-reviewed PR has been reviewed by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants