Skip to content

Commit 26f44b5

Browse files
[fix](filecache) add ttl mgr NOT_FOUND cleanup (#60269)
1. Drop missing tablet ids on NOT_FOUND to stop repeated TTL meta lookups and log spam 2. add bvar for tablet-id set size to monitor cleanup behavior
1 parent b1585e1 commit 26f44b5

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

‎be/src/io/cache/block_file_cache_ttl_mgr.cpp‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include "common/config.h"
2828
#include "common/logging.h"
29+
#include "common/status.h"
2930
#include "io/cache/block_file_cache.h"
3031
#include "io/cache/cache_block_meta_store.h"
3132
#include "io/cache/file_block.h"
@@ -37,6 +38,8 @@ namespace doris::io {
3738

3839
BlockFileCacheTtlMgr::BlockFileCacheTtlMgr(BlockFileCache* mgr, CacheBlockMetaStore* meta_store)
3940
: _mgr(mgr), _meta_store(meta_store), _stop_background(false) {
41+
_tablet_id_set_size_metrics = std::make_shared<bvar::Status<size_t>>(
42+
_mgr->get_base_path().c_str(), "file_cache_ttl_mgr_tablet_id_set_size", 0);
4043
// Start background threads
4144
_update_ttl_thread =
4245
std::thread(&BlockFileCacheTtlMgr::run_backgroud_update_ttl_info_map, this);
@@ -79,6 +82,9 @@ void BlockFileCacheTtlMgr::run_background_tablet_id_flush() {
7982
}
8083
std::lock_guard<std::mutex> lock(_tablet_id_mutex);
8184
_tablet_id_set.insert(items->begin(), items->end());
85+
if (_tablet_id_set_size_metrics) {
86+
_tablet_id_set_size_metrics->set_value(_tablet_id_set.size());
87+
}
8288
items->clear();
8389
};
8490

@@ -166,8 +172,22 @@ void BlockFileCacheTtlMgr::run_backgroud_update_ttl_info_map() {
166172
TabletMetaSharedPtr tablet_meta;
167173
auto meta_status = ExecEnv::get_tablet_meta(tablet_id, &tablet_meta, false);
168174
if (!meta_status.ok()) {
169-
LOG(WARNING) << "Failed to get tablet meta for tablet_id: " << tablet_id
170-
<< ", err: " << meta_status;
175+
if (meta_status.is<ErrorCode::NOT_FOUND>()) {
176+
{
177+
std::lock_guard<std::mutex> lock(_tablet_id_mutex);
178+
if (_tablet_id_set.erase(tablet_id) > 0 &&
179+
_tablet_id_set_size_metrics) {
180+
_tablet_id_set_size_metrics->set_value(_tablet_id_set.size());
181+
}
182+
}
183+
{
184+
std::lock_guard<std::mutex> lock(_ttl_info_mutex);
185+
_ttl_info_map.erase(tablet_id);
186+
}
187+
} else {
188+
LOG(WARNING) << "Failed to get tablet meta for tablet_id: " << tablet_id
189+
<< ", err: " << meta_status;
190+
}
171191
continue;
172192
}
173193

‎be/src/io/cache/block_file_cache_ttl_mgr.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919

2020
#pragma once
2121

22+
#include <bvar/bvar.h>
2223
#include <concurrentqueue.h>
2324

2425
#include <atomic>
2526
#include <map>
27+
#include <memory>
2628
#include <mutex>
2729
#include <thread>
2830
#include <unordered_set>
@@ -73,6 +75,8 @@ class BlockFileCacheTtlMgr {
7375
std::thread _tablet_id_flush_thread;
7476

7577
std::mutex _ttl_info_mutex;
78+
79+
std::shared_ptr<bvar::Status<size_t>> _tablet_id_set_size_metrics;
7680
};
7781

7882
} // namespace doris::io

0 commit comments

Comments
 (0)