From 0182931cfb39894141a6f94c3f4dbf54e9c3d897 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 9 Oct 2018 18:06:18 -0500 Subject: [PATCH] ceph-monstore-tool: rebuild creating_pgs In particular, we need to rebuild the created_pools set or else the mon will try to recreate every PG in the system. On an aged cluster, that is extremely expensive, and will break things. Fixes: http://tracker.ceph.com/issues/36306 Signed-off-by: Sage Weil --- src/tools/ceph_monstore_tool.cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/tools/ceph_monstore_tool.cc b/src/tools/ceph_monstore_tool.cc index 20db4db265876..29c38080d3371 100644 --- a/src/tools/ceph_monstore_tool.cc +++ b/src/tools/ceph_monstore_tool.cc @@ -33,6 +33,7 @@ #include "mon/MgrMap.h" #include "osd/OSDMap.h" #include "crush/CrushCompiler.h" +#include "mon/CreatingPGs.h" namespace po = boost::program_options; @@ -590,6 +591,35 @@ static int update_monitor(MonitorDBStore& st) return 0; } +// rebuild +// - creating_pgs +static int update_creating_pgs(MonitorDBStore& st) +{ + bufferlist bl; + auto last_osdmap_epoch = st.get("osdmap", "last_committed"); + int r = st.get("osdmap", st.combine_strings("full", last_osdmap_epoch), bl); + if (r < 0) { + cerr << "unable to losd osdmap e" << last_osdmap_epoch << std::endl; + return r; + } + + OSDMap osdmap; + osdmap.decode(bl); + creating_pgs_t creating; + for (auto& i : osdmap.get_pools()) { + creating.created_pools.insert(i.first); + } + creating.last_scan_epoch = last_osdmap_epoch; + + bufferlist newbl; + ::encode(creating, newbl); + + auto t = make_shared(); + t->put("osd_pg_creating", "creating", newbl); + st.apply_transaction(t); + return 0; +} + // rebuild // - mgr // - mgr_command_desc @@ -676,6 +706,9 @@ int rebuild_monstore(const char* progname, } if (!keyring_path.empty()) update_auth(st, keyring_path); + if ((r = update_creating_pgs(st))) { + return r; + } if ((r = update_mgrmap(st))) { return r; } -- 2.39.5