]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
DO NOT MERGE TO MAIN
authorJon Bailey <jonathan.bailey1@ibm.com>
Tue, 22 Jul 2025 10:30:44 +0000 (11:30 +0100)
committerJon <jonathan.bailey1@ibm.com>
Fri, 3 Oct 2025 13:31:28 +0000 (14:31 +0100)
Modifies log_stats to not leak memory. Also moves processing to only happen at log level 20.

Intentionally left unsigned to flag up in GitHub actions if it ends up in main.

Jon

src/osd/PrimaryLogPG.cc

index c4f31b27ad2e883b5dbf4e3dda06c835044cf524..840d9cb1827d935ad2c163b533558d4b326f7ce9 100644 (file)
@@ -9164,7 +9164,9 @@ void PrimaryLogPG::log_stats(hobject_t soid,
                              ObjectStore::Transaction& t,
                              bool is_delta)
 {
-  Formatter *f = Formatter::create("json");
+  std::map<hobject_t, int> soid_oi_set_count_map;
+
+  dout(20) << __func__ << ", soid: " << soid << " pg_stats ";
 
   std::string operation = "updated to ";
   if (is_delta)
@@ -9172,15 +9174,14 @@ void PrimaryLogPG::log_stats(hobject_t soid,
     operation = "delta applied ";
   }
 
+  *_dout << operation;
+
+  std::unique_ptr<Formatter> f(Formatter::create("json"));
   f->open_object_section("stats");
-  stats.dump(f);
+  stats.dump(f.get());
   f->close_section();
 
-  dout(20) << __func__ << ", soid: " << soid << " pg_stats " << operation;
   f->flush(*_dout);
-  *_dout << dendl;
-
-  std::map<hobject_t, int> soid_oi_set_count_map;
 
   ObjectStore::Transaction::iterator i = t.begin();
 
@@ -9219,10 +9220,10 @@ void PrimaryLogPG::log_stats(hobject_t soid,
           f->open_object_section("oi");
           i.decode_bl(bl);
           object_info_t oi(bl);
-          oi.dump(f);
+          oi.dump(f.get());
           f->close_section();
 
-          dout(20) << __func__ << ", soid: " << soid
+          dout(20) << "\n" << __func__ << ", soid: " << soid
                    << " setattr - OI set to ";
           f->flush(*_dout);
           *_dout << dendl;
@@ -9244,13 +9245,12 @@ void PrimaryLogPG::log_stats(hobject_t soid,
             f->open_object_section("oi");
             bl.append(p->second);
             object_info_t oi_decode(bl);
-            oi_decode.dump(f);
+            oi_decode.dump(f.get());
             f->close_section();
 
-            dout(20) << __func__ << ", soid: " << soid
+            *_dout << "\n" <<__func__ << ", soid: " << soid
                      << " setattrs - OI set to ";
             f->flush(*_dout);
-            *_dout << "bl: " << bl << dendl;
 
             soid_oi_set_count_map[soid]++;
           }
@@ -9291,12 +9291,15 @@ void PrimaryLogPG::log_stats(hobject_t soid,
     }
   }
 
+  *_dout << dendl;
+
   for (const auto&[soid, oi_set_count] : soid_oi_set_count_map)
   {
     if (oi_set_count > 1)
     {
+      std::unique_ptr<Formatter> f(Formatter::create("json"));
       f->open_object_section("t");
-      t.dump(f);
+      t.dump(f.get());
       f->close_section();
       dout(10) << __func__ << ", soid: " << soid
                << " INFO: oi set multiple ("