]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
Merge pull request #58728 from ifed01/wip-ifed-ret-error-kv-stats
authorIgor Fedotov <igor.fedotov@croit.io>
Tue, 17 Sep 2024 12:35:27 +0000 (15:35 +0300)
committerGitHub <noreply@github.com>
Tue, 17 Sep 2024 12:35:27 +0000 (15:35 +0300)
kv/rocksdb: return error for dump_objectstore_kv_stats asok command

Reviewed-by: Adam Kupczyk <akupczyk@ibm.com>
1  2 
src/kv/RocksDBStore.cc

index c2b0da79ef79767ea87c94b185b3f4238346f29d,bef87d15ed73b34731d2378995725dde213c21e2..ca63ea064841480429b4b4a44ba11e892ba0249c
@@@ -1417,28 -1417,21 +1417,33 @@@ int64_t RocksDBStore::estimate_prefix_s
  void RocksDBStore::get_statistics(Formatter *f)
  {
    if (!cct->_conf->rocksdb_perf)  {
-     dout(20) << __func__ << " RocksDB perf is disabled, can't probe for stats"
-            << dendl;
+     f->write_raw_data("error: RocksDB perf is disabled, can't probe for stats.\n");
+     return;
+   }
+   if (!cct->_conf->rocksdb_collect_compaction_stats &&
+       !cct->_conf->rocksdb_collect_extended_stats &&
+       !cct->_conf->rocksdb_collect_memory_stats)  {
+     f->write_raw_data("error: None of rocksdb_collect_* setting is enabled, hence no output.\n");
      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);