]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: stash newer map on bootstrap when addr doesn't match 33418/head
authorSage Weil <sage@redhat.com>
Wed, 19 Feb 2020 23:42:09 +0000 (17:42 -0600)
committerSage Weil <sage@redhat.com>
Wed, 19 Feb 2020 23:42:09 +0000 (17:42 -0600)
If we have to respawn because a newer monmap comes along where our addr or
rank changes, we need to use that on restart in order to make progress.
Stash the newer map in a temporary location and use it when we restart.

Don't bother cleaning up.  Having this map here is harmless, since we
only use it if it is newer than what is in paxos.

Fixes: https://tracker.ceph.com/issues/44076
Signed-off-by: Sage Weil <sage@redhat.com>
src/ceph_mon.cc
src/mon/Monitor.cc

index 117a94dc55ccbf90013f21be132f2d3655445454..f56d6914da5e3f7172018427a671317e8c69c068 100644 (file)
@@ -61,6 +61,7 @@ int obtain_monmap(MonitorDBStore &store, bufferlist &bl)
   dout(10) << __func__ << dendl;
   /*
    * the monmap may be in one of three places:
+   *  'mon_sync:temp_newer_monmap' - stashed newer map for bootstrap
    *  'monmap:<latest_version_no>' - the monmap we'd really like to have
    *  'mon_sync:latest_monmap'     - last monmap backed up for the last sync
    *  'mkfs:monmap'                - a monmap resulting from mkfs
@@ -74,6 +75,24 @@ int obtain_monmap(MonitorDBStore &store, bufferlist &bl)
       ceph_assert(bl.length() > 0);
       dout(10) << __func__ << " read last committed monmap ver "
                << latest_ver << dendl;
+
+      // see if there is stashed newer map (see bootstrap())
+      if (store.exists("mon_sync", "temp_newer_monmap")) {
+       bufferlist bl2;
+       int err = store.get("mon_sync", "temp_newer_monmap", bl2);
+       ceph_assert(err == 0);
+       ceph_assert(bl2.length() > 0);
+       MonMap b;
+       b.decode(bl2);
+       if (b.get_epoch() > latest_ver) {
+         dout(10) << __func__ << " using stashed monmap " << b.get_epoch()
+                  << " instead" << dendl;
+         bl.claim(bl2);
+       } else {
+         dout(10) << __func__ << " ignoring stashed monmap " << b.get_epoch()
+                  << dendl;
+       }
+      }
       return 0;
     }
   }
index 469cc17e3354ac6b6172a4297f96a23fdb6eab09..d8e2bb0f69ef084fca33a2f90c90b6aebaf2771a 100644 (file)
@@ -1153,6 +1153,19 @@ void Monitor::bootstrap()
            << messenger->get_myaddrs()
            << ", monmap is " << monmap->get_addrs(newrank) << ", respawning"
            << dendl;
+
+    if (monmap->get_epoch()) {
+      // store this map in temp mon_sync location so that we use it on
+      // our next startup
+      derr << " stashing newest monmap " << monmap->get_epoch()
+          << " for next startup" << dendl;
+      bufferlist bl;
+      monmap->encode(bl, -1);
+      auto t(std::make_shared<MonitorDBStore::Transaction>());
+      t->put("mon_sync", "temp_newer_monmap", bl);
+      store->apply_transaction(t);
+    }
+
     respawn();
   }
   if (newrank != rank) {