Skip to content

branch-4.1: [opt](file-cache) support config hot reload of file cache microbench in running state - #62595

Merged
yiguolei merged 1 commit into
apache:branch-4.1from
gavinchou:gavin-pick-58922-branch-4.1
Apr 25, 2026
Merged

branch-4.1: [opt](file-cache) support config hot reload of file cache microbench in running state#62595
yiguolei merged 1 commit into
apache:branch-4.1from
gavinchou:gavin-pick-58922-branch-4.1

Conversation

@gavinchou

Copy link
Copy Markdown
Contributor

Summary

Pick #58922 to branch-4.1

Changes

  • Add reload_file_cache method to FileCacheFactory for hot reloading file cache configuration
  • Add RELOAD operation to FileCacheAction HTTP endpoint
  • Refactor file_cache_microbench to support config hot reload in running state
    • Introduce BenchEnvManager class to manage config loading and reload worker
    • Add reload_config and show_reload_status RPC endpoints
    • Improve read buffer management in JobManager

Related Issue

close#58922

@Thearas

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@gavinchou

Copy link
Copy Markdown
ContributorAuthor

run buildall

@gavinchougavinchou changed the title [opt](file-cache) support config hot reload of file cache microbench in running statebranch-4.1: [opt](file-cache) support config hot reload of file cache microbench in running stateApr 18, 2026
@gavinchou
gavinchouforce-pushed the gavin-pick-58922-branch-4.1 branch from e3c830f to 2e49b76CompareApril 22, 2026 05:59
@gavinchou

Copy link
Copy Markdown
ContributorAuthor

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 0.00% (0/31) 🎉

Increment coverage report
Complete coverage report

CategoryCoverage
Function Coverage71.54% (26273/36723)
Line Coverage54.43% (277997/510776)
Region Coverage51.76% (231097/446491)
Branch Coverage53.17% (99934/187951)

@gavinchou

Copy link
Copy Markdown
ContributorAuthor

/review

github-actions[bot]
github-actionsBot previously requested changes Apr 23, 2026

@github-actionsgithub-actionsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary

Requesting changes.

The new hot-reload path currently has correctness issues in both the cache factory and the microbench service, and the read-path refactor introduces an eager buffer-allocation regression that can OOM large jobs.

Critical Checkpoints

  • Correctness: fail. Cache-path removals are silently ignored during reload, so the hot-reloaded configuration can diverge from the active cache set.
  • Concurrency/thread-safety: fail. reload_file_cache() destroys live BlockFileCache instances even though callers use raw pointers and assume _caches is immutable after startup.
  • Reliability/operability: fail. /reload_config never executes a normal reload, the microbench now preallocates one max-sized read buffer per file, and startup can crash if DORIS_HOME is unset.
  • Testing/validation: not evidenced in this diff for the new reload paths.
  • Repository approval policy (tools/maintainers/check_review.py): not satisfied until the PR has 2 latest-state APPROVED reviews.

User Focus

No additional user-provided review focus was supplied.

return Status::OK();
}

Status FileCacheFactory::reload_file_cache(const std::vector<CachePath>& cache_base_paths) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

reload_file_cache() says file-cache count changes are unsupported, but this only validates additions. If the new config removes an existing path, the method still succeeds and leaves the old BlockFileCache in _caches/_path_to_cache, so pick_one_cache_path() and get_by_path() can continue routing traffic to a cache that is no longer configured. We should reject removals as well, or explicitly rebuild the full cache set.

}

// deconstruct target reload first
*cache_iter = std::unique_ptr<BlockFileCache>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Destroying and replacing the live BlockFileCache in place is not safe here. get_by_path() and several other callers return raw BlockFileCache* without taking _mtx, and this file explicitly documents that _caches is treated as immutable after startup. A concurrent reload can therefore free a cache object while reads/evictions are still using it, turning this into a use-after-free. It also drops the old cache before initialize() succeeds. We need a publish/swap scheme that preserves the old instance until users are quiesced or otherwise protected.


std::string reload_details_stat() {
return _reloading.load() ? "Reloading config" : "Reload finished or not started";
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

reload_request() sets _reloading = true and calls notify_one(), but this wait predicate only returns when _stop_thread is true. In other words, normal reload requests never wake the worker, so /reload_config returns OK while no reload ever runs, and /show_reload_status can stay stuck at Reloading config forever. The JobCount == 0 gating mentioned in the comment also is not implemented.

}

private:
doris::S3ClientConf create_s3_client_conf(const JobConfig& config) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Preallocating read_buffers for every entry in read_files changes the memory footprint from roughly O(num_threads * read_length) to O(num_files * read_length_right). For large jobs this can allocate gigabytes up front and OOM the microbench even though only num_threads reads run concurrently. The previous code only kept a buffer per active task.

auto status = exec_env->init_mem_env();

std::unique_ptr<doris::ThreadPool> s3_upload_pool;
static_cast<void>(doris::ThreadPoolBuilder("MicrobenchS3FileUploadThreadPool")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

getenv() can return nullptr. Constructing std::string directly from that is undefined / throws before we even reach the empty() check, so the tool can crash immediately when DORIS_HOME is not exported. The old code explicitly handled the unset case by defaulting to ".".

@github-actionsgithub-actionsBot added the approved Indicates a PR has been approved by one committer. label Apr 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@yiguolei
yiguolei merged commit b850896 into apache:branch-4.1Apr 25, 2026
30 of 34 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approvedIndicates a PR has been approved by one committer.reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@gavinchou@Thearas@hello-stephen@yiguolei@LHG41278