This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.1 by this push:
new 5a742877a72 branch-4.1: [fix](filecache) avoid BE crash when finalize
misses local cache writer #62389 (#63179)
5a742877a72 is described below
commit 5a742877a72ff2ed10a021b531f3fb55d91db2af
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed May 13 11:42:47 2026 +0800
branch-4.1: [fix](filecache) avoid BE crash when finalize misses local
cache writer #62389 (#63179)
Cherry-picked from #62389
Co-authored-by: zhengyu <[email protected]>
---
be/src/io/cache/fs_file_cache_storage.cpp | 8 +++++++-
be/test/io/cache/block_file_cache_test.cpp | 17 +++++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/be/src/io/cache/fs_file_cache_storage.cpp
b/be/src/io/cache/fs_file_cache_storage.cpp
index a9e829329b1..029d37425e5 100644
--- a/be/src/io/cache/fs_file_cache_storage.cpp
+++ b/be/src/io/cache/fs_file_cache_storage.cpp
@@ -214,7 +214,13 @@ Status FSFileCacheStorage::finalize(const FileCacheKey&
key, const size_t size)
std::lock_guard lock(_mtx);
auto file_writer_map_key = std::make_pair(key.hash, key.offset);
auto iter = _key_to_writer.find(file_writer_map_key);
- DCHECK(iter != _key_to_writer.end());
+ if (iter == _key_to_writer.end()) {
+ return Status::InternalError(
+ "file cache finalize missing writer, hash={}, offset={},
type={}, "
+ "expiration={}",
+ key.hash.to_string(), key.offset,
cache_type_to_string(key.meta.type),
+ key.meta.expiration_time);
+ }
file_writer = std::move(iter->second);
_key_to_writer.erase(iter);
}
diff --git a/be/test/io/cache/block_file_cache_test.cpp
b/be/test/io/cache/block_file_cache_test.cpp
index b857ebe8e2f..d4ae09df5b7 100644
--- a/be/test/io/cache/block_file_cache_test.cpp
+++ b/be/test/io/cache/block_file_cache_test.cpp
@@ -7876,6 +7876,23 @@ TEST_F(BlockFileCacheTest, finalize_partial_block) {
}
}
+TEST_F(BlockFileCacheTest,
fs_file_cache_storage_finalize_missing_writer_returns_error) {
+ FSFileCacheStorage storage;
+ FileCacheKey key;
+ key.hash = io::BlockFileCache::hash("finalize-missing-writer");
+ key.offset = 4096;
+ key.meta.type = io::FileCacheType::NORMAL;
+ key.meta.expiration_time = 0;
+ key.meta.tablet_id = 0;
+
+ auto st = storage.finalize(key, 4096);
+
+ EXPECT_TRUE(st.is<ErrorCode::INTERNAL_ERROR>()) << st;
+ EXPECT_TRUE(st.to_string().find("file cache finalize missing writer") !=
std::string::npos)
+ << st;
+ EXPECT_TRUE(st.to_string().find("offset=4096") != std::string::npos) << st;
+}
+
TEST_F(BlockFileCacheTest, set_downloaded_empty_block_branch) {
FileCacheKey key;
key.hash = io::BlockFileCache::hash("set_downloaded_empty_block_branch");
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]