@@ -338,6 +338,13 @@ pegasus_server_impl::pegasus_server_impl(dsn::replication::replica *r)
338338 snprintf (name, 255 , " rdb.memtable.memory_usage@%s" , str_gpid.c_str ());
339339 _pfc_rdb_memtable_mem_usage.init_app_counter (
340340 " app.pegasus" , name, COUNTER_TYPE_NUMBER, " statistic the memory usage of rocksdb memtable" );
341+
342+ snprintf (name, 255 , " rdb.estimate_num_keys@%s" , str_gpid.c_str ());
343+ _pfc_rdb_estimate_num_keys.init_app_counter (
344+ " app.pegasus" ,
345+ name,
346+ COUNTER_TYPE_NUMBER,
347+ " statistics the estimated number of keys inside the rocksdb" );
341348}
342349
343350void pegasus_server_impl::parse_checkpoints ()
@@ -2242,6 +2249,14 @@ void pegasus_server_impl::update_replica_rocksdb_statistics()
22422249 _pfc_rdb_memtable_mem_usage->set (val);
22432250 dinfo_replica (" _pfc_rdb_memtable_mem_usage: {} bytes" , val);
22442251 }
2252+
2253+ // for the same n kv pairs, kEstimateNumKeys will be counted n times, you need compaction to
2254+ // remove duplicate
2255+ if (_db->GetProperty (rocksdb::DB::Properties::kEstimateNumKeys , &str_val) &&
2256+ dsn::buf2uint64 (str_val, val)) {
2257+ _pfc_rdb_estimate_num_keys->set (val);
2258+ dinfo_replica (" _pfc_rdb_estimate_num_keys: {}" , val);
2259+ }
22452260}
22462261
22472262void pegasus_server_impl::update_server_rocksdb_statistics ()
0 commit comments