]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: stash newer map on bootstrap when addr doesn't match 34500/head
authorSage Weil <sage@redhat.com>
Wed, 19 Feb 2020 23:42:09 +0000 (17:42 -0600)
committerVicente Cheng <freeze.bilsted@gmail.com>
Fri, 10 Apr 2020 07:24:07 +0000 (07:24 +0000)
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>
(cherry picked from commit 71befa298658925555841a2a98802210954358ce)

src/ceph_mon.cc
src/mon/Monitor.cc

index 2d73294b4096fb483530117eb1f5b878d7296b51..24bfe1b7c74e05dcbd050a3060fb85feaab4f366 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 cd634d349b1ae715da7df809823cc99c50ec0603..21f16a0efee3e3447223c9efc6aec82102c2633e 100644 (file)
@@ -1149,6 +1149,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) {