From cd013ed417c0317da0249c6360f16a26894c82a1 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 2 Feb 2018 12:07:58 -0600 Subject: [PATCH] mon/OSDMonitor: ignore and/or remove pgs that shouldn't exist The update_creating_pgs() change is there mainly for clusters that already have an invalid pg in the map; going forward they hopefully shouldn't appear! Fixes: https://tracker.ceph.com/issues/22847 Signed-off-by: Sage Weil --- src/mon/OSDMonitor.cc | 24 ++++++++++++++++++++++-- src/mon/OSDMonitor.h | 3 ++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index e6b9279003ba4..db191381cd9ea 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -644,7 +644,8 @@ void OSDMonitor::create_pending() } creating_pgs_t -OSDMonitor::update_pending_pgs(const OSDMap::Incremental& inc) +OSDMonitor::update_pending_pgs(const OSDMap::Incremental& inc, + const OSDMap& nextmap) { dout(10) << __func__ << dendl; creating_pgs_t pending_creatings; @@ -687,6 +688,20 @@ OSDMonitor::update_pending_pgs(const OSDMap::Incremental& inc) pending_creatings.last_scan_epoch = osdmap.get_epoch(); } + // filter out any pgs that shouldn't exist. + { + auto i = pending_creatings.pgs.begin(); + while (i != pending_creatings.pgs.end()) { + if (!nextmap.pg_exists(i->first)) { + dout(10) << __func__ << " removing pg " << i->first + << " which should not exist" << dendl; + i = pending_creatings.pgs.erase(i); + } else { + ++i; + } + } + } + // process queue unsigned max = std::max(1, g_conf->mon_osd_max_creating_pgs); const auto total = pending_creatings.pgs.size(); @@ -1288,7 +1303,7 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t) pending_metadata_rm.clear(); // and pg creating, also! - auto pending_creatings = update_pending_pgs(pending_inc); + auto pending_creatings = update_pending_pgs(pending_inc, tmp); bufferlist creatings_bl; encode(pending_creatings, creatings_bl); t->put(OSD_PG_CREATING_PREFIX, "creating", creatings_bl); @@ -3282,6 +3297,11 @@ void OSDMonitor::update_creating_pgs() for (const auto& pg : creating_pgs.pgs) { int acting_primary = -1; auto pgid = pg.first; + if (!osdmap.pg_exists(pgid)) { + dout(20) << __func__ << " ignoring " << pgid << " which should not exist" + << dendl; + continue; + } auto mapped = pg.second.first; dout(20) << __func__ << " looking up " << pgid << "@" << mapped << dendl; mapping.get(pgid, nullptr, nullptr, nullptr, &acting_primary); diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 24052d725534c..4db2767839e86 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -463,7 +463,8 @@ protected: creating_pgs_t creating_pgs; mutable std::mutex creating_pgs_lock; - creating_pgs_t update_pending_pgs(const OSDMap::Incremental& inc); + creating_pgs_t update_pending_pgs(const OSDMap::Incremental& inc, + const OSDMap& nextmap); void trim_creating_pgs(creating_pgs_t *creating_pgs, const ceph::unordered_map& pgm); unsigned scan_for_creating_pgs( -- 2.39.5