This is an automated email from the ASF dual-hosted git repository.

yiguolei 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 4a02d1d0563 branch-4.0: [fix](filecache) fix crash when clear file 
cache #56170 (#56585)
4a02d1d0563 is described below

commit 4a02d1d05635c111855edc596e5aa7a957d733fc
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Mon Sep 29 11:16:46 2025 +0800

    branch-4.0: [fix](filecache) fix crash when clear file cache #56170 (#56585)
    
    Cherry-picked from #56170
    
    Signed-off-by: zhengyu <[email protected]>
    Co-authored-by: zhengyu <[email protected]>
---
 be/src/io/cache/block_file_cache.cpp | 12 ++++++++++++
 be/src/io/cache/block_file_cache.h   |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/be/src/io/cache/block_file_cache.cpp 
b/be/src/io/cache/block_file_cache.cpp
index f9013f8d2c7..62f8e2a3f22 100644
--- a/be/src/io/cache/block_file_cache.cpp
+++ b/be/src/io/cache/block_file_cache.cpp
@@ -663,7 +663,9 @@ std::string BlockFileCache::clear_file_cache_async() {
                 ++num_cells_to_delete;
             }
         }
+        clear_need_update_lru_blocks();
     }
+
     std::stringstream ss;
     ss << "finish clear_file_cache_async, path=" << _cache_base_path
        << " num_files_all=" << num_files_all << " num_cells_all=" << 
num_cells_all
@@ -2258,6 +2260,13 @@ bool 
BlockFileCache::try_reserve_during_async_load(size_t size,
     return !_disk_resource_limit_mode || removed_size >= size;
 }
 
+void BlockFileCache::clear_need_update_lru_blocks() {
+    std::vector<FileBlockSPtr> buffer;
+    buffer.reserve(1024);
+    while (_need_update_lru_blocks.try_dequeue_bulk(buffer.data(), 
buffer.capacity())) {
+    }
+}
+
 std::string BlockFileCache::clear_file_cache_directly() {
     _lru_dumper->remove_lru_dump_files();
     using namespace std::chrono;
@@ -2300,6 +2309,9 @@ std::string BlockFileCache::clear_file_cache_directly() {
     _normal_queue.clear(cache_lock);
     _disposable_queue.clear(cache_lock);
     _ttl_queue.clear(cache_lock);
+
+    clear_need_update_lru_blocks();
+
     ss << "finish clear_file_cache_directly"
        << " path=" << _cache_base_path
        << " time_elapsed_ms=" << 
duration_cast<milliseconds>(steady_clock::now() - start).count()
diff --git a/be/src/io/cache/block_file_cache.h 
b/be/src/io/cache/block_file_cache.h
index 46fbc56bd30..ae9d412789c 100644
--- a/be/src/io/cache/block_file_cache.h
+++ b/be/src/io/cache/block_file_cache.h
@@ -455,6 +455,8 @@ private:
                                size_t& offset, size_t& size);
     void remove_lru_dump_files();
 
+    void clear_need_update_lru_blocks();
+
     // info
     std::string _cache_base_path;
     size_t _capacity = 0;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to