From c87535241e61b26ce1f4ee3cf2521b369deed1cd Mon Sep 17 00:00:00 2001 From: deardeng Date: Fri, 26 Jun 2026 17:54:55 +0800 Subject: [PATCH] [fix](be) Fix file cache queue evict size metrics ### What problem does this PR solve? Issue Number: None Related PR: None Problem Summary: File cache queue evict size metrics were constructed with literal array indexes, while increments use FileCacheType enum values. Because FileCacheType maps DISPOSABLE to 0 and INDEX to 2, file_cache_index_queue_evict_size actually counted disposable queue evictions, and file_cache_disposable_queue_evict_size counted index queue evictions. This change initializes the metrics array with explicit FileCacheType indexes so each bvar name matches the queue type that increments it. ### Release note None ### Check List (For Author) - Test: Manual test - Ran Doris commit precheck. - Ran git diff --check and git diff --cached --check. - Attempted build-support/check-format.sh, but the available clang-format is version 20/18 and the script requires version 16. - Attempted build-support/run-clang-tidy.sh --build-dir be/build_Release, but the current environment reports missing system header stddef.h and pre-existing clang-tidy errors in included/existing code. - Behavior changed: Yes. File cache queue evict size bvar metrics now report the queue matching their metric names. - Does this need documentation: No --- be/src/io/cache/block_file_cache.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/be/src/io/cache/block_file_cache.cpp b/be/src/io/cache/block_file_cache.cpp index 47940b9e83afa4..a7a199355a1769 100644 --- a/be/src/io/cache/block_file_cache.cpp +++ b/be/src/io/cache/block_file_cache.cpp @@ -206,13 +206,13 @@ BlockFileCache::BlockFileCache(const std::string& cache_base_path, _cur_disposable_queue_cache_size_metrics = std::make_shared>( _cache_base_path.c_str(), "file_cache_disposable_queue_cache_size", 0); - _queue_evict_size_metrics[0] = std::make_shared>( - _cache_base_path.c_str(), "file_cache_index_queue_evict_size"); - _queue_evict_size_metrics[1] = std::make_shared>( - _cache_base_path.c_str(), "file_cache_normal_queue_evict_size"); - _queue_evict_size_metrics[2] = std::make_shared>( + _queue_evict_size_metrics[FileCacheType::DISPOSABLE] = std::make_shared>( _cache_base_path.c_str(), "file_cache_disposable_queue_evict_size"); - _queue_evict_size_metrics[3] = std::make_shared>( + _queue_evict_size_metrics[FileCacheType::NORMAL] = std::make_shared>( + _cache_base_path.c_str(), "file_cache_normal_queue_evict_size"); + _queue_evict_size_metrics[FileCacheType::INDEX] = std::make_shared>( + _cache_base_path.c_str(), "file_cache_index_queue_evict_size"); + _queue_evict_size_metrics[FileCacheType::TTL] = std::make_shared>( _cache_base_path.c_str(), "file_cache_ttl_cache_evict_size"); _total_evict_size_metrics = std::make_shared>( _cache_base_path.c_str(), "file_cache_total_evict_size"); @@ -1554,7 +1554,7 @@ void BlockFileCache::remove(FileBlockSPtr file_block, T& cache_lock, U& block_lo cell->file_block->get_hash_value(), cell->file_block->offset(), cell->size()); } - *_queue_evict_size_metrics[static_cast(file_block->cache_type())] + *_queue_evict_size_metrics[file_cache_type_index(file_block->cache_type())] << file_block->range().size(); *_total_evict_size_metrics << file_block->range().size();