]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: don't dump global config holding gil 50194/head
authorMykola Golub <mgolub@suse.com>
Fri, 16 Dec 2022 16:14:29 +0000 (16:14 +0000)
committerMykola Golub <mgolub@suse.com>
Tue, 21 Feb 2023 08:53:05 +0000 (10:53 +0200)
When dumping the config the cpython may drop/take the gil which
may lead to a deadlock when another cpython thread is trying to
get the config lock while holding the gil.

Fixes: https://tracker.ceph.com/issues/58269
Signed-off-by: Mykola Golub <mgolub@suse.com>
(cherry picked from commit 133a46e8fd96f24184d129a4b0898c65263221a2)

src/mgr/ActivePyModules.cc

index 6a8525b37b28ef4743b9d3cf78c4fd0b09028ed5..8cafc0edf17850a984da358bb82a098cc8465730 100644 (file)
@@ -253,10 +253,16 @@ PyObject *ActivePyModules::get_python(const std::string &what)
     }
     f.close_section();
   } else if (what.substr(0, 6) == "config") {
+    // We make a copy of the global config to avoid printing
+    // to py formater (which may drop-take GIL) while holding
+    // the global config lock, which might deadlock with other
+    // thread that is holding the GIL and acquiring the global
+    // config lock.
+    ConfigProxy config{g_conf()};
     if (what == "config_options") {
-      g_conf().config_options(&f);
+      config.config_options(&f);
     } else if (what == "config") {
-      g_conf().show_config(&f);
+      config.show_config(&f);
     }
   } else if (what == "mon_map") {
     without_gil_t no_gil;