Skip to content

[FLINK-40097][historyserver] Introduce Lazy Loading for HistoryServer#28685

Open
chenzihao5 wants to merge 3 commits into
apache:masterfrom
chenzihao5:FLINK-40097-lazy-loading-of-hs
Open

[FLINK-40097][historyserver] Introduce Lazy Loading for HistoryServer#28685
chenzihao5 wants to merge 3 commits into
apache:masterfrom
chenzihao5:FLINK-40097-lazy-loading-of-hs

Conversation

@chenzihao5

Copy link
Copy Markdown
Contributor

What is the purpose of the change

Introduce a lazy-loading mode that loads archive details on demand, improving archive load times and enhancing the user experience.

Brief change log

  • Introduce three configurations:
    • historyserver.archive.load.mode to specify the loading mode, supports EAGER(default) and LAZY
    • historyserver.lazy.fetch.executor.common.pool-size and historyserver.lazy.fetch.executor.individual.pool-size to control the loading thread pool
  • Add PENDING, OVERVIEW_PARSING, OVERVIEW_CREATED, DETAIL_PARSING in ArchiveEventType.
  • Support lazy-loading in org.apache.flink.runtime.webmonitor.history.AbstractHistoryServerHandler#loadResource.

Verifying this change

This change added tests and can be verified as follows:

  • Added unit tests for lazy-loading mode, verify the different stages when lazy loading archive by BlockingArchiveStorage.
  • Added unit tests for other functions that are included in this feature.

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): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
  • The S3 file system connector: no

Documentation

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

Was generative AI tooling used to co-author this PR?
  • Yes (Claude-4.7-Opus 1M Context)

@flinkbot

flinkbot commented Jul 8, 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


In `LAZY` mode, on-demand fetches use two thread pools:

* `historyserver.lazy.fetch.executor.common.pool-size` (default: `4`) — The size of the shared thread pool used for routine, background archive fetching.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I suggest remove the default value here, because we might forget to sync the documentation when changing default values.


/** Creates an {@link ArchiveStorage} instance under the given temporary directory. */
@FunctionalInterface
interface ArchiveStorageFactory<T> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is unused.


/** Creates an {@link ArchiveStorage} instance under the given temporary directory. */
@FunctionalInterface
interface ArchiveStorageFactory<T> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can be removed.

throw new FlinkException("Unsupported archive storage type: " + archiveStorageType);
}

Map<String, ArchiveMetaInfo> archiveMetaInfoCache = new HashMap<>();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this map thread safe? it's better to check the race condition.

Comment on lines +166 to +170
this.commonFetchExecutor =
Executors.newFixedThreadPool(
lazyFetchExecutorCommonPoolSize,
new ExecutorThreadFactory("HistoryServer-commonFetchExecutor"));
this.individualFetchExecutor =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Where are these two thread pools being shut-down?


if (!overviewCreated && detailArchives.isEmpty()) {
archiveMetaInfoCache.remove(jobId);
throw new RuntimeException("Archive of job " + jobId + " is empty");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This RuntimeException will propagate to the catch (Exception e) block in the scanArchives method. Is this as expected?


/** Container for the {@link Path} and {@link FileSystem} of a refresh directory. */
static class RefreshLocation {
public static class RefreshLocation {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is the purpose of making these change?

this.archivePath = archivePath;
}

public String getArchiveId() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Never used method.

Comment on lines +536 to +537
if (!archiveMetaInfoCache.containsKey(jobId)) {
archiveMetaInfoCache.put(jobId, new ArchiveMetaInfo(jobId, PENDING, jobArchive));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this thread-safe? containsKey + put is not an atomic operation.

I think we should add some comments to declare the thread-safe semantic for archiveMetaInfoCache.

@chenzihao5 chenzihao5 force-pushed the FLINK-40097-lazy-loading-of-hs branch from 683fc9f to 1339960 Compare July 15, 2026 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants