Skip to content

Commit 793f192

Browse files
authored
Merge branch 'master' into refactor_datacache_session_switchvar
2 parents 0872a85 + f26b21d commit 793f192

File tree

52 files changed

+3121
-539
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3121
-539
lines changed

be/src/common/config.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,11 @@ DEFINE_mDouble(file_cache_keep_base_compaction_output_min_hit_ratio, "0.7");
12011201
// if difference below this threshold, we consider cache's progressive upgrading (2.0->3.0) successful
12021202
DEFINE_mDouble(file_cache_meta_store_vs_file_system_diff_num_threshold, "0.3");
12031203
DEFINE_mDouble(file_cache_keep_schema_change_output_min_hit_ratio, "0.7");
1204+
DEFINE_mDouble(file_cache_leak_fs_to_meta_ratio_threshold, "1.3");
1205+
DEFINE_mInt64(file_cache_leak_scan_interval_seconds, "86400");
1206+
DEFINE_mInt32(file_cache_leak_scan_batch_files, "2048");
1207+
DEFINE_mInt32(file_cache_leak_scan_pause_ms, "500");
1208+
DEFINE_mInt64(file_cache_leak_grace_seconds, "3600");
12041209

12051210
DEFINE_mInt64(file_cache_remove_block_qps_limit, "1000");
12061211
DEFINE_mInt64(file_cache_background_gc_interval_ms, "100");

be/src/common/config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,11 @@ DECLARE_mBool(enable_file_cache_adaptive_write);
12301230
DECLARE_mDouble(file_cache_keep_base_compaction_output_min_hit_ratio);
12311231
DECLARE_mDouble(file_cache_meta_store_vs_file_system_diff_num_threshold);
12321232
DECLARE_mDouble(file_cache_keep_schema_change_output_min_hit_ratio);
1233+
DECLARE_mDouble(file_cache_leak_fs_to_meta_ratio_threshold);
1234+
DECLARE_mInt64(file_cache_leak_scan_interval_seconds);
1235+
DECLARE_mInt32(file_cache_leak_scan_batch_files);
1236+
DECLARE_mInt32(file_cache_leak_scan_pause_ms);
1237+
DECLARE_mInt64(file_cache_leak_grace_seconds);
12331238
DECLARE_mInt64(file_cache_remove_block_qps_limit);
12341239
DECLARE_mInt64(file_cache_background_gc_interval_ms);
12351240
DECLARE_mInt64(file_cache_background_block_lru_update_interval_ms);

be/src/io/cache/cache_block_meta_store.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,33 @@ std::unique_ptr<BlockMetaIterator> CacheBlockMetaStore::get_all() {
332332
return std::unique_ptr<BlockMetaIterator>(new RocksDBIterator(iter));
333333
}
334334

335+
size_t CacheBlockMetaStore::approximate_entry_count() const {
336+
if (!_db) {
337+
LOG(WARNING) << "Database not initialized when counting entries";
338+
return 0;
339+
}
340+
341+
rocksdb::ReadOptions read_options;
342+
std::unique_ptr<rocksdb::Iterator> iter(
343+
_db->NewIterator(read_options, _file_cache_meta_cf_handle.get()));
344+
if (!iter) {
345+
LOG(WARNING) << "Failed to create iterator when counting entries";
346+
return 0;
347+
}
348+
349+
size_t count = 0;
350+
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
351+
++count;
352+
}
353+
354+
if (!iter->status().ok()) {
355+
LOG(WARNING) << "Iterator encountered error when counting entries: "
356+
<< iter->status().ToString();
357+
}
358+
359+
return count;
360+
}
361+
335362
void CacheBlockMetaStore::delete_key(const BlockMetaKey& key) {
336363
std::string key_str = serialize_key(key);
337364

be/src/io/cache/cache_block_meta_store.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ class CacheBlockMetaStore {
111111
// Get the approximate size of the write queue
112112
size_t get_write_queue_size() const;
113113

114+
// Count entries stored in rocksdb (ignoring pending writes)
115+
size_t approximate_entry_count() const;
116+
114117
private:
115118
void async_write_worker();
116119

0 commit comments

Comments
 (0)