]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/BaseMgrModule: drop GIL in set_config
authorxie xingguo <xie.xingguo@zte.com.cn>
Sat, 30 Mar 2019 03:15:49 +0000 (11:15 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Sat, 27 Apr 2019 02:33:35 +0000 (10:33 +0800)
Holding GIL and run mon_command turns out to be easily deadlock-prone.
https://tracker.ceph.com/issues/35985 is a typical report, and here is
another.

Fix by using PyModuleConfig's own lock for protection of concurrent
accesses, which should be sufficient.

Fixes: http://tracker.ceph.com/issues/39040
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
(cherry picked from commit 96b7319cc92e13198e05398921404959005c26d9)

Conflicts:
- there are new ceph_store_{set,get} commands
          (and many other mgr changes) in Nautilus and later

src/mgr/ActivePyModules.cc
src/mgr/BaseMgrModule.cc

index 5e6c62b70e7cc4baf73f0c8f100aa7826e9946ce..5e2fa1b5540af7a809e9d54dc2b4950afa906457 100644 (file)
@@ -464,9 +464,7 @@ void ActivePyModules::set_config(const std::string &module_name,
 
   Command set_cmd;
   {
-    PyThreadState *tstate = PyEval_SaveThread();
     Mutex::Locker l(lock);
-    PyEval_RestoreThread(tstate);
     if (val) {
       config_cache[global_key] = *val;
     } else {
index 790991cfe6b2637728aafd633d025385497f3274..a0b329c9bd43fbd51c606bc4aab00b3e65f4bbb4 100644 (file)
@@ -406,7 +406,9 @@ ceph_config_set(BaseMgrModule *self, PyObject *args)
   if (value) {
     val = value;
   }
+  PyThreadState *tstate = PyEval_SaveThread();
   self->py_modules->set_config(self->this_module->get_name(), key, val);
+  PyEval_RestoreThread(tstate);
 
   Py_RETURN_NONE;
 }