Uh oh!
There was an error while loading. Please reload this page.
[fix](filecache) fix clear_file_cache right after reboot causing file cache size percent overflow - #63410
Conversation
### What problem does this PR solve? Issue Number: None Related PR: None Problem Summary: When file cache LRU restore creates a block from dump metadata and later lazy loading finds the same hash/offset with a smaller real file size, reset_range only updated the LRU queue size and _cur_cache_size. The FileBlock range still kept the old restored size, so a later async clear or eviction subtracted the old block size and could underflow _cur_cache_size, producing huge size_percent values in need-evict-cache-in-advance logs. This change makes reset_range update the FileBlock range as the single place that keeps the FileBlock, LRU queue, _cur_cache_size, and TTL size accounting consistent. FileBlock::finalize now delegates the range shrink to reset_range instead of changing the range before calling it. ### Release note None ### Check List (For Author) - Test: Unit Test / Manual test - Added BE UT BlockFileCacheTest.lru_restore_size_mismatch_does_not_underflow_on_clear - Ran build-support/clang-format.sh with clang-format 16 - Ran build-support/check-format.sh with clang-format 16 - Ran DORIS_TOOLCHAIN=clang DISABLE_BE_JAVA_EXTENSIONS=ON ENABLE_INJECTION_POINT=ON ENABLE_CACHE_LOCK_DEBUG=0 ENABLE_PCH=0 sh run-be-ut.sh --run --filter=BlockFileCacheTest.lru_restore_size_mismatch_does_not_underflow_on_clear - Behavior changed: No - Does this need documentation: No
hello-stephen
commented
May 19, 2026
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
freemandealer
commented
May 19, 2026
run buildall |
hello-stephen
commented
May 19, 2026
TPC-H: Total hot run time: 31750 ms |
hello-stephen
commented
May 19, 2026
TPC-DS: Total hot run time: 168581 ms |
hello-stephen
commented
May 19, 2026
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
freemandealer
commented
May 20, 2026
run external |
freemandealer
commented
May 20, 2026
run cloud_p0 |
PR approved by at least one committer and no changes requested. |
PR approved by anyone and no changes requested. |
freemandealer
commented
Jun 1, 2026
/review |
There was a problem hiding this comment.
I found one blocking issue in the updated file-cache resize flow.
Critical checkpoint conclusions:
- Goal/test: The PR addresses stale FileBlock range accounting after LRU restore and adds a BE unit test for the restored DOWNLOADED block shrink-and-clear case.
- Scope: The change is small and focused, but one existing shrink-only assertion no longer matches the widened reset_range contract.
- Concurrency/lifecycle: The affected code is reachable during asynchronous cache loading started by FSFileCacheStorage::init while foreground cache downloads may be creating tmp files; the cache mutex protects manager structures, but the finalized size can legitimately grow relative to a range that was shrunk by async tmp-file observation.
- Compatibility/storage format: No incompatible storage-format or protocol change was found.
- Parallel paths: The restore/lazy-load path and downloader finalize path were both checked; the missing adjustment is in the downloader finalize path.
- Tests: The new test covers the restored DOWNLOADED shrink case, but it does not cover the concurrent async-load tmp-file path where finalize sees new_size > old_size.
- Observability: No new observability appears necessary for this accounting fix.
- Transaction/persistence/data correctness: This is file-cache metadata/accounting only, not transaction visibility; the issue is a debug/ASAN assertion failure risk in a valid lifecycle path.
User focus: No additional user-provided review focus was specified.
Uh oh!
There was an error while loading. Please reload this page.
reset is only used in shrink. there is no such case when reset enlarging size in doris
Uh oh!
There was an error while loading. Please reload this page.
… cache size percent overflow (#63410) Problem Summary: When file cache LRU restore creates a block from dump metadata and later lazy loading finds the same hash/offset with a smaller real file size, reset_range only updated the LRU queue size and _cur_cache_size. The FileBlock range still kept the old restored size, so a later async clear or eviction subtracted the old block size and could underflow _cur_cache_size, producing huge size_percent values in need-evict-cache-in-advance logs. This change makes reset_range update the FileBlock range as the single place that keeps the FileBlock, LRU queue, _cur_cache_size, and TTL size accounting consistent. FileBlock::finalize now delegates the range shrink to reset_range instead of changing the range before calling it.
… cache size percent overflow (apache#63410) Problem Summary: When file cache LRU restore creates a block from dump metadata and later lazy loading finds the same hash/offset with a smaller real file size, reset_range only updated the LRU queue size and _cur_cache_size. The FileBlock range still kept the old restored size, so a later async clear or eviction subtracted the old block size and could underflow _cur_cache_size, producing huge size_percent values in need-evict-cache-in-advance logs. This change makes reset_range update the FileBlock range as the single place that keeps the FileBlock, LRU queue, _cur_cache_size, and TTL size accounting consistent. FileBlock::finalize now delegates the range shrink to reset_range instead of changing the range before calling it.
Issue Number: None Related PR: None Problem Summary: When file cache LRU restore creates a block from dump metadata and later lazy loading finds the same hash/offset with a smaller real file size, reset_range only updated the LRU queue size and _cur_cache_size. The FileBlock range still kept the old restored size, so a later async clear or eviction subtracted the old block size and could underflow _cur_cache_size, producing huge size_percent values in need-evict-cache-in-advance logs. This change makes reset_range update the FileBlock range as the single place that keeps the FileBlock, LRU queue, _cur_cache_size, and TTL size accounting consistent. FileBlock::finalize now delegates the range shrink to reset_range instead of changing the range before calling it. None - Test: Unit Test / Manual test - Added BE UT BlockFileCacheTest.lru_restore_size_mismatch_does_not_underflow_on_clear - Ran build-support/clang-format.sh with clang-format 16 - Ran build-support/check-format.sh with clang-format 16 - Ran DORIS_TOOLCHAIN=clang DISABLE_BE_JAVA_EXTENSIONS=ON ENABLE_INJECTION_POINT=ON ENABLE_CACHE_LOCK_DEBUG=0 ENABLE_PCH=0 sh run-be-ut.sh --run --filter=BlockFileCacheTest.lru_restore_size_mismatch_does_not_underflow_on_clear - Behavior changed: No - Does this need documentation: No Picked from: apache#63410
…causing file cache size percent overflow(pick#63410) (#64233) Original PR: #63410 Picked to: branch-4.0 Pick branch: freemandealer:pick-branch-4.0-pr-63410 Validation: - git diff --check - build-support/check-format.sh with clang-format 16 - DORIS_TOOLCHAIN=clang DISABLE_BE_JAVA_EXTENSIONS=ON ENABLE_INJECTION_POINT=ON ENABLE_CACHE_LOCK_DEBUG=0 ENABLE_PCH=0 sh run-be-ut.sh --run --filter=BlockFileCacheTest.lru_restore_size_mismatch_does_not_underflow_on_clear Notes: Resolved block_file_cache.h comment conflict against branch-4.0. Fixed block_file_cache_test.cpp to match the branch-4.0 FSFileCacheStorage::handle_already_loaded_block signature.
What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary: When file cache LRU restore creates a block from dump metadata and later lazy loading finds the same hash/offset with a smaller real file size, reset_range only updated the LRU queue size and _cur_cache_size. The FileBlock range still kept the old restored size, so a later async clear or eviction subtracted the old block size and could underflow _cur_cache_size, producing huge size_percent values in need-evict-cache-in-advance logs. This change makes reset_range update the FileBlock range as the single place that keeps the FileBlock, LRU queue, _cur_cache_size, and TTL size accounting consistent. FileBlock::finalize now delegates the range shrink to reset_range instead of changing the range before calling it.
Release note
None
What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)