From e6b8938eff145ed5ee2c510e96ccd2cc5f13e39a Mon Sep 17 00:00:00 2001 From: Laura Flores Date: Thu, 10 Nov 2022 17:25:04 -0600 Subject: [PATCH] osd: shut down the MgrClient before osd_fast_shutdown We should shut down the MgrClient before osd_fast_shutdown. This approach avoids a race condition that sometimes occurs when the MgrClient attempts to gather `pg_stats` from the database after it has been unmounted, or when it is in the process of being unmounted. Fixes: https://tracker.ceph.com/issues/56101 Signed-off-by: Laura Flores Signed-off-by: Brad Hubbard (cherry picked from commit 77ebbf580bee3bf83de0da03487b6ebb08c17d76) --- src/osd/OSD.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 839c4fd364dcf..df9e61db8bd80 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -4311,6 +4311,12 @@ int OSD::shutdown() cct->_conf.apply_changes(nullptr); } + // stop MgrClient earlier as it's more like an internal consumer of OSD + // + // should occur before unmounting the database in fast-shutdown to avoid + // a race condition (see https://tracker.ceph.com/issues/56101) + mgrc.shutdown(); + if (cct->_conf->osd_fast_shutdown) { // first, stop new task from being taken from op_shardedwq // and clear all pending tasks @@ -4350,9 +4356,6 @@ int OSD::shutdown() _exit(0); } - // stop MgrClient earlier as it's more like an internal consumer of OSD - mgrc.shutdown(); - service.start_shutdown(); // stop sending work to pgs. this just prevents any new work in _process -- 2.39.5