From ff44ecf1c5d9396e5344431d22d3edde9cded029 Mon Sep 17 00:00:00 2001 From: zhengyu Date: Mon, 18 Nov 2024 12:09:11 +0800 Subject: [PATCH] [fix](cloud) fix BlockFileCache::get_or_set crash (#44013) This is a Plan-B fix, the root cause is under study: 2# JVM_handle_linux_signal in /usr/lib/jvm/java-17-openjdk-amd64/lib/server/libjvm.so 3# 0x00007F8CFE720520 in /lib/x86_64-linux-gnu/libc.so.6 4# std::_Rb_tree_decrement(std::_Rb_tree_node_base*) at ../../../../../libstdc++-v3/src/c++98/tree.cc:123 5# doris::io::BlockFileCache::get_impl[abi:cxx11](doris::io::UInt128Wrapper const&, doris::io::CacheContext const&, doris::io::FileBlock::Range const&, std::lock_guard&) at /home/zcp/repo_center/doris_branch-3.0/doris/be/src/io/cache/block_file_cache.cpp:365 6# doris::io::BlockFileCache::get_or_set(doris::io::UInt128Wrapper const&, unsigned long, unsigned long, doris::io::CacheContext&) at /home/zcp/repo_center/doris_branch-3.0/doris/be/src/io/cache/block_file_cache.cpp:662 7# doris::io::CachedRemoteFileReader::read_at_impl(unsigned long, doris::Slice, unsigned long*, doris::io::IOContext const*) at /home/zcp/repo_center/doris_branch-3.0/doris/be/src/io/cache/cached_remote_file_reader.cpp:179 Signed-off-by: zhengyu --- be/src/io/cache/block_file_cache.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/be/src/io/cache/block_file_cache.cpp b/be/src/io/cache/block_file_cache.cpp index 596afb64232b5b..ebcbe9135daa35 100644 --- a/be/src/io/cache/block_file_cache.cpp +++ b/be/src/io/cache/block_file_cache.cpp @@ -393,6 +393,15 @@ FileBlocks BlockFileCache::get_impl(const UInt128Wrapper& hash, const CacheConte auto& file_blocks = it->second; DCHECK(!file_blocks.empty()); + if (file_blocks.empty()) { + LOG(WARNING) << "file_blocks is empty for hash=" << hash.to_string() + << " cache type=" << context.cache_type + << " cache expiration time=" << context.expiration_time + << " cache range=" << range.left << " " << range.right + << " query id=" << context.query_id; + _files.erase(hash); + return {}; + } // change to ttl if the blocks aren't ttl if (context.cache_type == FileCacheType::TTL && _key_to_time.find(hash) == _key_to_time.end()) { for (auto& [_, cell] : file_blocks) {