From a5680f6bb4ae467a5eaf33a199983084f6647c58 Mon Sep 17 00:00:00 2001 From: Jon Bailey Date: Tue, 22 Jul 2025 11:30:44 +0100 Subject: [PATCH] DO NOT MERGE TO MAIN 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 | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 0a363e977ef..ac093d9b474 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -9166,7 +9166,9 @@ void PrimaryLogPG::log_stats(hobject_t soid, ObjectStore::Transaction& t, bool is_delta) { - Formatter *f = Formatter::create("json"); + std::map soid_oi_set_count_map; + + dout(20) << __func__ << ", soid: " << soid << " pg_stats "; std::string operation = "updated to "; if (is_delta) @@ -9174,15 +9176,14 @@ void PrimaryLogPG::log_stats(hobject_t soid, operation = "delta applied "; } + *_dout << operation; + + std::unique_ptr 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 soid_oi_set_count_map; ObjectStore::Transaction::iterator i = t.begin(); @@ -9221,10 +9222,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; @@ -9246,13 +9247,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]++; } @@ -9293,12 +9293,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 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 (" -- 2.39.5