]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
kv/RocksDBStore: add kv_stats function to print all CF info 58718/head
authorwanglinke <wanglinke@cmss.chinamobile.com>
Mon, 22 Jul 2024 10:40:02 +0000 (18:40 +0800)
committerwanglinke <wanglinke@cmss.chinamobile.com>
Tue, 23 Jul 2024 12:09:41 +0000 (20:09 +0800)
- Added the function of printing all cf's rocksdb level information.
- Currently, only the default cf information is printed.
- Print all cf information to facilitate observation
of the level to which rocksdb is written.
- The main purpose is to observe the usage of db/ssd.

co-author: Jrchyang Yu <yuzhiqiang_yewu@cmss.chinamobile.com>
Signed-off-by: Wang Linke <wanglinke_yewu@cmss.chinamobile.com>
src/kv/RocksDBStore.cc

index a653fa6398c29b182bb1a8d7f034014cc6d43ad9..c2b0da79ef79767ea87c94b185b3f4238346f29d 100644 (file)
@@ -1421,21 +1421,34 @@ void RocksDBStore::get_statistics(Formatter *f)
             << dendl;
     return;
   }
-
+  
   if (cct->_conf->rocksdb_collect_compaction_stats) {
-    std::string stat_str;
-    bool status = db->GetProperty("rocksdb.stats", &stat_str);
-    if (status) {
-      f->open_object_section("rocksdb_statistics");
+    vector<rocksdb::ColumnFamilyHandle*> handles;
+    handles.push_back(default_cf);
+    for (auto cf : cf_handles) {
+      for (auto shard_cf : cf.second.handles) {
+        handles.push_back(shard_cf);
+      }
+    }
+    f->open_object_section("rocksdb_statistics");
+    for (auto handle : handles) {
+      std::string stat_str;
+      bool status = db->GetProperty(handle, "rocksdb.stats", &stat_str);
+      if (!status) {
+        derr << __func__ << " failed to get rocksdb.stats for the cf: " 
+             << handle->GetName() << dendl;
+        continue;
+      } 
       f->dump_string("rocksdb_compaction_statistics", "");
       vector<string> stats;
       split_stats(stat_str, '\n', stats);
       for (auto st :stats) {
         f->dump_string("", st);
-      }
-      f->close_section();
+      }  
     }
+    f->close_section();
   }
+
   if (cct->_conf->rocksdb_collect_extended_stats) {
     if (dbstats) {
       f->open_object_section("rocksdb_extended_statistics");