This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.0 by this push:
new 5b73b7dd5c0 branch-4.0: [fix](filecache) avoid BE crash when finalize
misses local cache writer #62389 (#63178)
5b73b7dd5c0 is described below
commit 5b73b7dd5c05f6eafbb1228f5e19ee75c9c307a3
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Jun 10 18:11:00 2026 +0900
branch-4.0: [fix](filecache) avoid BE crash when finalize misses local
cache writer #62389 (#63178)
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 | 16 ++++++++++++++++
2 files changed, 23 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 48448e142ea..23dd905541f 100644
--- a/be/src/io/cache/fs_file_cache_storage.cpp
+++ b/be/src/io/cache/fs_file_cache_storage.cpp
@@ -165,7 +165,13 @@ Status FSFileCacheStorage::finalize(const FileCacheKey&
key) {
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 1cdf7f62ec2..a968d46dea9 100644
--- a/be/test/io/cache/block_file_cache_test.cpp
+++ b/be/test/io/cache/block_file_cache_test.cpp
@@ -8429,6 +8429,22 @@ 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;
+
+ auto st = storage.finalize(key);
+
+ 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]