From 1bbf30e1d326143c7d00dba972da8adbbcf66055 Mon Sep 17 00:00:00 2001 From: Kamoltat Date: Thu, 6 Apr 2023 17:36:55 +0000 Subject: [PATCH] mon/Monitor.cc: exit function if !osdmon()->is_writeable() Problem: In the function `maybe_go_degraded_stretch_mode()` when `osdmon` is not writeable we shouldn't go into `trigger_degraded_stretch_mode` because we will crash at `ceph_assert(osdmon()->is_writeable())`. The current code does not exit `maybe_go_degraded_stretch_mode()` when we are waiting for `osdmon` to be writeable, therefore, we crash. Solution: Exit the function by returning nothing after going into `wait_for_writeable_ctx`, since at that point we would have queued the context and all we have to do is wait for finish context to execute `maybe_go_degraded_stretch_mode` again. Also, added a bit of logging so that user is aware when `osdmon` and `monmon` are not writeable. We fix other parts of the monitor code that are missing the return after `wait_for_writeable_ctx` and `wait_for_readable_ctx` as well. Fixes: https://tracker.ceph.com/issues/59271 Signed-off-by: Kamoltat (cherry picked from commit 7f7c2d51c60c58aeb031ec279a48910bc02444de) --- src/mon/Monitor.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index e2b4a3109d7..e1e9ffd255a 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -6647,7 +6647,9 @@ void Monitor::try_engage_stretch_mode() dout(20) << __func__ << dendl; if (stretch_mode_engaged) return; if (!osdmon()->is_readable()) { + dout(20) << "osdmon is not readable" << dendl; osdmon()->wait_for_readable_ctx(new CMonEnableStretchMode(this)); + return; } if (osdmon()->osdmap.stretch_mode_enabled && monmap->stretch_mode_enabled) { @@ -6730,12 +6732,15 @@ void Monitor::go_recovery_stretch_mode() } if (!osdmon()->is_readable()) { + dout(20) << "osdmon is not readable" << dendl; osdmon()->wait_for_readable_ctx(new CMonGoRecovery(this)); return; } if (!osdmon()->is_writeable()) { + dout(20) << "osdmon is not writeable" << dendl; osdmon()->wait_for_writeable_ctx(new CMonGoRecovery(this)); + return; } osdmon()->trigger_recovery_stretch_mode(); } @@ -6771,10 +6776,14 @@ void Monitor::maybe_go_degraded_stretch_mode() &matched_down_mons); if (dead) { if (!osdmon()->is_writeable()) { + dout(20) << "osdmon is not writeable" << dendl; osdmon()->wait_for_writeable_ctx(new CMonGoDegraded(this)); + return; } if (!monmon()->is_writeable()) { + dout(20) << "monmon is not writeable" << dendl; monmon()->wait_for_writeable_ctx(new CMonGoDegraded(this)); + return; } trigger_degraded_stretch_mode(matched_down_mons, matched_down_buckets); } @@ -6824,10 +6833,14 @@ void Monitor::trigger_healthy_stretch_mode() if (!is_degraded_stretch_mode()) return; if (!is_leader()) return; if (!osdmon()->is_writeable()) { + dout(20) << "osdmon is not writeable" << dendl; osdmon()->wait_for_writeable_ctx(new CMonGoHealthy(this)); + return; } if (!monmon()->is_writeable()) { + dout(20) << "monmon is not writeable" << dendl; monmon()->wait_for_writeable_ctx(new CMonGoHealthy(this)); + return; } ceph_assert(osdmon()->osdmap.recovering_stretch_mode); -- 2.47.3