From 88595d1344a0e9a7d2c508b9cf97a13e74b46493 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 (cherry picked from commit cd013ed417c0317da0249c6360f16a26894c82a1) Conflicts: src/mon/OSDMonitor.cc (luminous does not have d0a477bfec5dec6d70bb5c7de918f8258b9116f6) --- 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 5a0a91d8487b0..20900280788c4 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -684,7 +684,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; @@ -735,6 +736,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 = MAX(1, g_conf->mon_osd_max_creating_pgs); const auto total = pending_creatings.pgs.size(); @@ -1373,7 +1388,7 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t) // and pg creating, also! if (mon->monmap->get_required_features().contains_all( ceph::features::mon::FEATURE_LUMINOUS)) { - auto pending_creatings = update_pending_pgs(pending_inc); + auto pending_creatings = update_pending_pgs(pending_inc, tmp); if (osdmap.get_epoch() && osdmap.require_osd_release < CEPH_RELEASE_LUMINOUS) { dout(7) << __func__ << " in the middle of upgrading, " @@ -3407,6 +3422,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 9767f10035780..af6e01af9b383 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -453,7 +453,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