From: Greg Farnum Date: Mon, 22 Mar 2021 20:56:14 +0000 (+0000) Subject: mon: notify_new_monmap in all the places we update our monmap X-Git-Tag: v16.2.5~92^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=48466c2324416806cb5ebd8d57bf7e40dfd9eb1c;p=ceph.git mon: notify_new_monmap in all the places we update our monmap We can adopt new monmaps while bootstrapping, or in election messages, in addition to MonmapMonitor::update_from_paxos. Since we use the notification to update our election strategy and such, we need to notify from these locations as well! Fixes: https://tracker.ceph.com/issues/47654 Signed-off-by: Greg Farnum (cherry picked from commit 1d5f4e879e50a537ef6db51f7e519a03ab586cd5) Fixes: https://tracker.ceph.com/issues/50087 --- diff --git a/src/mon/Elector.cc b/src/mon/Elector.cc index cb1a675a5d97..79b227a9c653 100644 --- a/src/mon/Elector.cc +++ b/src/mon/Elector.cc @@ -633,6 +633,7 @@ void Elector::dispatch(MonOpRequestRef op) mon->store->apply_transaction(t); //mon->monmon()->paxos->stash_latest(mon->monmap->epoch, em->monmap_bl); cancel_timer(); + mon->notify_new_monmap(false); mon->bootstrap(); return; } diff --git a/src/mon/Elector.h b/src/mon/Elector.h index 1ecf566d9d6d..d14dbb5c4ce9 100644 --- a/src/mon/Elector.h +++ b/src/mon/Elector.h @@ -368,6 +368,8 @@ class Elector : public ElectionOwner, RankProvider { void notify_rank_changed(int new_rank); /** * A peer has been removed so we should clean up state related to it. + * This is safe to call even if we haven't joined or are currently + * in a quorum. */ void notify_rank_removed(int rank_removed); void notify_strategy_maybe_changed(int strategy); diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 11677b562e03..bc34069f39d8 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -2000,6 +2000,7 @@ void Monitor::handle_probe_reply(MonOpRequestRef op) << ", mine was " << monmap->get_epoch() << dendl; delete newmap; monmap->decode(m->monmap_bl); + notify_new_monmap(false); bootstrap(); return; @@ -6504,7 +6505,7 @@ int Monitor::ms_handle_authentication(Connection *con) return ret; } -void Monitor::notify_new_monmap() +void Monitor::notify_new_monmap(bool can_change_external_state) { elector.notify_strategy_maybe_changed(monmap->strategy); dout(30) << __func__ << "we have " << monmap->removed_ranks.size() << " removed ranks" << dendl; @@ -6524,7 +6525,7 @@ void Monitor::notify_new_monmap() set_degraded_stretch_mode(); } } - set_elector_disallowed_leaders(true); + set_elector_disallowed_leaders(can_change_external_state); } void Monitor::set_elector_disallowed_leaders(bool allow_election) diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 19972c27631b..cd624f001f6d 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -840,7 +840,10 @@ public: void waitlist_or_zap_client(MonOpRequestRef op); void send_mon_message(Message *m, int rank); - void notify_new_monmap(); + /** can_change_external_state if we can do things like + * call elections as a result of the new map. + */ + void notify_new_monmap(bool can_change_external_state=false); public: struct C_Command : public C_MonOp { diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index 5e9774704e5b..80ca4de24e6a 100644 --- a/src/mon/MonmapMonitor.cc +++ b/src/mon/MonmapMonitor.cc @@ -121,7 +121,7 @@ void MonmapMonitor::update_from_paxos(bool *need_bootstrap) stringify(ceph_release())); } - mon.notify_new_monmap(); + mon.notify_new_monmap(true); } void MonmapMonitor::create_pending()