[fix](filecache) avoid BE crash when finalize misses local cache writer#62389
Conversation
FSFileCacheStorage::finalize() relied on DCHECK to assume the writer entry was always present in _key_to_writer. In release builds a missing entry could still fall through, dereference end(), and crash BE. Return InternalError when finalize cannot find the writer instead of touching an invalid iterator. The existing FileBlock::set_downloaded() failure path already aborts the pending cache write and resets the block state, so the failure becomes recoverable and diagnosable. Add a BE unit test that covers the missing-writer finalize path.
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
|
run buildall |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
|
run buildall |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
1 similar comment
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
|
skip buildall |
…er (#62389) ## Problem `FSFileCacheStorage::finalize()` relied on `DCHECK` to assume the writer entry always existed in `_key_to_writer`. In release builds a missing writer entry could still fall through, dereference `end()`, and crash BE. ## Root Cause When `(hash, offset)` is missing from `_key_to_writer`, the current finalize path moves and erases through an invalid iterator. The target branch already uses the newer `finalize(key, size)` signature, so this PR ports the hardening change to that path. ## Solution - return `InternalError` immediately when finalize cannot find the writer entry - include hash, offset, cache type, and expiration time in the error message for diagnosis - keep the normal finalize path unchanged when the writer exists - rely on the existing `FileBlock::set_downloaded()` cleanup path to abort the pending cache write and reset block state ## Tests - `BlockFileCacheTest.fs_file_cache_storage_finalize_missing_writer_returns_error` - `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 --clean --run --filter=BlockFileCacheTest.fs_file_cache_storage_finalize_missing_writer_returns_error -j 39` - Source patch: `selectdb/selectdb-core#8321`
…er (#62389) ## Problem `FSFileCacheStorage::finalize()` relied on `DCHECK` to assume the writer entry always existed in `_key_to_writer`. In release builds a missing writer entry could still fall through, dereference `end()`, and crash BE. ## Root Cause When `(hash, offset)` is missing from `_key_to_writer`, the current finalize path moves and erases through an invalid iterator. The target branch already uses the newer `finalize(key, size)` signature, so this PR ports the hardening change to that path. ## Solution - return `InternalError` immediately when finalize cannot find the writer entry - include hash, offset, cache type, and expiration time in the error message for diagnosis - keep the normal finalize path unchanged when the writer exists - rely on the existing `FileBlock::set_downloaded()` cleanup path to abort the pending cache write and reset block state ## Tests - `BlockFileCacheTest.fs_file_cache_storage_finalize_missing_writer_returns_error` - `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 --clean --run --filter=BlockFileCacheTest.fs_file_cache_storage_finalize_missing_writer_returns_error -j 39` - Source patch: `selectdb/selectdb-core#8321`
Problem
FSFileCacheStorage::finalize()relied onDCHECKto assume the writer entry always existed in_key_to_writer. In release builds a missing writer entry could still fall through, dereferenceend(), and crash BE.Root Cause
When
(hash, offset)is missing from_key_to_writer, the current finalize path moves and erases through an invalid iterator. The target branch already uses the newerfinalize(key, size)signature, so this PR ports the hardening change to that path.Solution
InternalErrorimmediately when finalize cannot find the writer entryFileBlock::set_downloaded()cleanup path to abort the pending cache write and reset block stateTests
BlockFileCacheTest.fs_file_cache_storage_finalize_missing_writer_returns_errorDORIS_TOOLCHAIN=clang DISABLE_BE_JAVA_EXTENSIONS=ON ENABLE_INJECTION_POINT=ON ENABLE_CACHE_LOCK_DEBUG=0 ENABLE_PCH=0 sh run-be-ut.sh --clean --run --filter=BlockFileCacheTest.fs_file_cache_storage_finalize_missing_writer_returns_error -j 39selectdb/selectdb-core#8321