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
3839BlockFileCacheTtlMgr::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
0 commit comments