]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: ignore and/or remove pgs that shouldn't exist 20267/head
authorSage Weil <sage@redhat.com>
Fri, 2 Feb 2018 18:07:58 +0000 (12:07 -0600)
committerSage Weil <sage@redhat.com>
Fri, 2 Feb 2018 18:25:00 +0000 (12:25 -0600)
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 <sage@redhat.com>
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h

index e6b9279003ba4b0db8af4f839a8cf981ad1fb4f6..db191381cd9eaf3f16ad04fa92e764340f116115 100644 (file)
@@ -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<int64_t>(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);
index 24052d725534cbb02555eae6d5d978bb3a3d3e98..4db2767839e86a63c8aacf05f6a2088d2a48f48c 100644 (file)
@@ -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<pg_t,pg_stat_t>& pgm);
   unsigned scan_for_creating_pgs(