]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/ActivePyModules.cc: fix cases where GIL is held while attempting to lock mutex 46302/head
authorCory Snyder <csnyder@iland.com>
Tue, 17 May 2022 09:24:53 +0000 (05:24 -0400)
committerCory Snyder <csnyder@iland.com>
Tue, 17 May 2022 10:00:13 +0000 (06:00 -0400)
The mgr process can deadlock if the GIL is held while attempting to lock a mutex.
Relevant regressions were introduced in commit a356bac. This fixes those regressions
and also cleans up some unnecessary yielding of the GIL.

Fixes: https://tracker.ceph.com/issues/55687
Signed-off-by: Cory Snyder <csnyder@iland.com>
src/mgr/ActivePyModules.cc

index 404476279fec945bd8b1a470438e01a8c6bfd1f8..beab72850048b9b1c5033ee11117ef0c0e494867 100644 (file)
@@ -252,8 +252,6 @@ PyObject *ActivePyModules::get_python(const std::string &what)
     }
     f.close_section();
   } else if (what.substr(0, 6) == "config") {
-    without_gil_t no_gil;
-    with_gil_t with_gil{no_gil};
     if (what == "config_options") {
       g_conf().config_options(&f);
     } else if (what == "config") {
@@ -415,8 +413,6 @@ PyObject *ActivePyModules::get_python(const std::string &what)
       pg_map.dump_pool_stats(&f);
     });
   } else if (what == "pg_ready") {
-    without_gil_t no_gil;
-    with_gil_t with_gil{no_gil};
     server.dump_pg_ready(&f);
   } else if (what == "pg_progress") {
     without_gil_t no_gil;
@@ -439,9 +435,9 @@ PyObject *ActivePyModules::get_python(const std::string &what)
     });
   } else if (what == "osd_pool_stats") {
     int64_t poolid = -ENOENT;
+    without_gil_t no_gil;
     cluster_state.with_osdmap_and_pgmap([&](const OSDMap& osdmap,
                                            const PGMap& pg_map) {
-      without_gil_t no_gil;
       with_gil_t with_gil{no_gil};
       f.open_array_section("pool_stats");
       for (auto &p : osdmap.get_pools()) {
@@ -471,8 +467,6 @@ PyObject *ActivePyModules::get_python(const std::string &what)
     });
   } else if (what == "mgr_ips") {
     entity_addrvec_t myaddrs = server.get_myaddrs();
-    without_gil_t no_gil;
-    with_gil_t with_gil{no_gil};
     f.open_array_section("ips");
     std::set<std::string> did;
     for (auto& i : myaddrs.v) {
@@ -483,13 +477,11 @@ PyObject *ActivePyModules::get_python(const std::string &what)
     }
     f.close_section();
   } else if (what == "have_local_config_map") {
-    without_gil_t no_gil;
-    with_gil_t with_gil{no_gil};
     f.dump_bool("have_local_config_map", have_local_config_map);
   } else if (what == "active_clean_pgs"){
+    without_gil_t no_gil;
     cluster_state.with_pgmap(
         [&](const PGMap &pg_map) {
-      without_gil_t no_gil;
       with_gil_t with_gil{no_gil};
       f.open_array_section("pg_stats");
       for (auto &i : pg_map.pg_stat) {
@@ -511,12 +503,8 @@ PyObject *ActivePyModules::get_python(const std::string &what)
     });
   } else {
     derr << "Python module requested unknown data '" << what << "'" << dendl;
-    without_gil_t no_gil;
-    with_gil_t with_gil{no_gil};
     Py_RETURN_NONE;
   }
-  without_gil_t no_gil;
-  no_gil.acquire_gil();
   if(ttl_seconds) {
     return jf.get();
   } else {