]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-objectstore-tool: update-mon-db: do not fail if incmap is missing 30979/head
authorKefu Chai <kchai@redhat.com>
Mon, 12 Aug 2019 02:12:28 +0000 (10:12 +0800)
committerNathan Cutler <ncutler@suse.com>
Thu, 17 Oct 2019 16:25:38 +0000 (18:25 +0200)
there is chance that we could use an OSD which does not have incmap of a
certain epoch for rebuilding the monstore. and since OSD does not read
and store the incmap if the MOSDMap message already has the fullmap of
that fullmap, and if an OSD does not have previous fullmap, monitor
will just send it the fullmao. so it's not unusual that an OSD has
a fullmap of some epoch without corresponding incmap.

Fixes: https://tracker.ceph.com/issues/41177
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 2e2414b3df97b22ccc54500830c24b28597ce75f)

src/tools/rebuild_mondb.cc

index 6994b08e0d0962bc2402119e742dcb50868d538c..a02edc9871261c4fb792404d993a2a83613f3dea 100644 (file)
@@ -244,13 +244,13 @@ int update_osdmap(ObjectStore& fs, OSDSuperblock& sb, MonitorDBStore& ms)
     uint32_t crc = -1;
     uint64_t features = 0;
     // add inc maps
-    {
+    auto add_inc_result = [&] {
       const auto oid = OSD::get_inc_osdmap_pobject_name(e);
       bufferlist bl;
       int nread = fs.read(ch, oid, 0, 0, bl);
       if (nread <= 0) {
-        cerr << "missing " << oid << std::endl;
-        return -EINVAL;
+        cout << "missing " << oid << std::endl;
+        return -ENOENT;
       }
       t->put(prefix, e, bl);
 
@@ -277,6 +277,17 @@ int update_osdmap(ObjectStore& fs, OSDSuperblock& sb, MonitorDBStore& ms)
           // inc.decode() verifies `inc_crc`, so it's been taken care of.
         }
       }
+    }();
+    switch (add_inc_result) {
+    case -ENOENT:
+      // no worries, we always have full map
+      break;
+    case -EINVAL:
+      return -EINVAL;
+    case 0:
+      break;
+    default:
+      assert(0);
     }
     // add full maps
     {