From: Patrick Donnelly Date: Wed, 6 Nov 2019 03:51:17 +0000 (-0800) Subject: mds: establish session with mgr only after added to FSMap X-Git-Tag: v14.2.10~168^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7f7d37375daeb917171a2c21229474ffee2cba7f;p=ceph.git mds: establish session with mgr only after added to FSMap Note that we now sub to the mgrmap after init because the MgrClient connection to the mgr is driven by receipt of the MgrMap. This is important so that the MDS does not have metadata with the mgr when the mons are ignoring the MDS otherwise due to CompatSet incompatibilities. Fixes: https://tracker.ceph.com/issues/41538 Fixes: https://tracker.ceph.com/issues/42635 Signed-off-by: Patrick Donnelly (cherry picked from commit e765f2d533440cfc4189f36fcaba24617a302e84) Conflicts: src/mds/MDSDaemon.cc Nautilus uses Lock/Unlock rather than lock/unlock in master. --- diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc index 276d23268707..d9699366a1fb 100644 --- a/src/mds/MDSDaemon.cc +++ b/src/mds/MDSDaemon.cc @@ -416,9 +416,6 @@ int MDSDaemon::init() return -ETIMEDOUT; } - mgrc.init(); - messenger->add_dispatcher_head(&mgrc); - mds_lock.Lock(); if (beacon.get_want_state() == CEPH_MDS_STATE_DNE) { dout(4) << __func__ << ": terminated already, dropping out" << dendl; @@ -427,7 +424,6 @@ int MDSDaemon::init() } monc->sub_want("mdsmap", 0, 0); - monc->sub_want("mgrmap", 0, 0); monc->renew_subs(); mds_lock.Unlock(); @@ -832,6 +828,14 @@ void MDSDaemon::handle_mds_map(const MMDSMap::const_ref &m) respawn(); } + if (old_state == DS::STATE_NULL && new_state != DS::STATE_NULL) { + /* The MDS has been added to the FSMap, now we can init the MgrClient */ + mgrc.init(); + messenger->add_dispatcher_tail(&mgrc); + monc->sub_want("mgrmap", 0, 0); + monc->renew_subs(); /* MgrMap receipt drives connection to ceph-mgr */ + } + // mark down any failed peers for (const auto& [gid, info] : oldmap->get_mds_info()) { if (mdsmap->get_mds_info().count(gid) == 0) { @@ -933,7 +937,8 @@ void MDSDaemon::suicide() } beacon.shutdown(); - mgrc.shutdown(); + if (mgrc.is_initialized()) + mgrc.shutdown(); if (mds_rank) { mds_rank->shutdown(); diff --git a/src/mgr/MgrClient.cc b/src/mgr/MgrClient.cc index 0d768dd21665..738e9a3b1169 100644 --- a/src/mgr/MgrClient.cc +++ b/src/mgr/MgrClient.cc @@ -44,6 +44,7 @@ void MgrClient::init() ceph_assert(msgr != nullptr); timer.init(); + initialized = true; } void MgrClient::shutdown() diff --git a/src/mgr/MgrClient.h b/src/mgr/MgrClient.h index 35c36e23fd8c..e7a6cc779f3d 100644 --- a/src/mgr/MgrClient.h +++ b/src/mgr/MgrClient.h @@ -153,10 +153,14 @@ public: std::map &&task_status); void update_daemon_health(std::vector&& metrics); + bool is_initialized() const { return initialized; } + private: void _send_stats(); void _send_pgstats(); void _send_report(); + + bool initialized = false; }; #endif