From d4ee81c694b21a8808cf4afa880cc73bccfc21a7 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 c4f31b27ad2..840d9cb1827 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -9164,7 +9164,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) @@ -9172,15 +9174,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(); @@ -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 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