From: Sage Weil Date: Wed, 19 Feb 2020 23:42:09 +0000 (-0600) Subject: mon: stash newer map on bootstrap when addr doesn't match X-Git-Tag: v14.2.10~108^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=12cacbd277fb33cd65108c15554237cc76243c4f;p=ceph.git mon: stash newer map on bootstrap when addr doesn't match 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 (cherry picked from commit 71befa298658925555841a2a98802210954358ce) --- diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc index 2d73294b4096..24bfe1b7c74e 100644 --- a/src/ceph_mon.cc +++ b/src/ceph_mon.cc @@ -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:' - 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; } } diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index cd634d349b1a..21f16a0efee3 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -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()); + t->put("mon_sync", "temp_newer_monmap", bl); + store->apply_transaction(t); + } + respawn(); } if (newrank != rank) {