From: xie xingguo Date: Sat, 30 Mar 2019 03:15:49 +0000 (+0800) Subject: mgr/BaseMgrModule: drop GIL in set_config X-Git-Tag: v12.2.13~169^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a87fce0b87dc11acbeb5ed1767e7c3a056dee88d;p=ceph.git mgr/BaseMgrModule: drop GIL in set_config 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 (cherry picked from commit 96b7319cc92e13198e05398921404959005c26d9) Conflicts: - there are new ceph_store_{set,get} commands (and many other mgr changes) in Nautilus and later --- diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index 5e6c62b70e7c..5e2fa1b5540a 100644 --- a/src/mgr/ActivePyModules.cc +++ b/src/mgr/ActivePyModules.cc @@ -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 { diff --git a/src/mgr/BaseMgrModule.cc b/src/mgr/BaseMgrModule.cc index 790991cfe6b2..a0b329c9bd43 100644 --- a/src/mgr/BaseMgrModule.cc +++ b/src/mgr/BaseMgrModule.cc @@ -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; }