From 96b7319cc92e13198e05398921404959005c26d9 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Sat, 30 Mar 2019 11:15:49 +0800 Subject: [PATCH 1/2] 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 enough. Fixes: http://tracker.ceph.com/issues/39040 Signed-off-by: xie xingguo --- src/mgr/BaseMgrModule.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mgr/BaseMgrModule.cc b/src/mgr/BaseMgrModule.cc index 899a8917e60..87eda069d50 100644 --- a/src/mgr/BaseMgrModule.cc +++ b/src/mgr/BaseMgrModule.cc @@ -443,7 +443,9 @@ ceph_set_module_option(BaseMgrModule *self, PyObject *args) if (value) { val = value; } + PyThreadState *tstate = PyEval_SaveThread(); self->py_modules->set_config(module, key, val); + PyEval_RestoreThread(tstate); Py_RETURN_NONE; } From 5108860c385cc1d905588d2e92d80295e3222ca4 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Sat, 30 Mar 2019 11:26:19 +0800 Subject: [PATCH 2/2] mgr/BaseMgrModule: drop GIL in ceph_store_set Signed-off-by: xie xingguo --- src/mgr/ActivePyModules.cc | 3 --- src/mgr/BaseMgrModule.cc | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index 0f3f508eb6f..745a34e301b 100644 --- a/src/mgr/ActivePyModules.cc +++ b/src/mgr/ActivePyModules.cc @@ -593,10 +593,7 @@ void ActivePyModules::set_store(const std::string &module_name, Command set_cmd; { - PyThreadState *tstate = PyEval_SaveThread(); std::lock_guard l(lock); - PyEval_RestoreThread(tstate); - if (val) { store_cache[global_key] = *val; } else { diff --git a/src/mgr/BaseMgrModule.cc b/src/mgr/BaseMgrModule.cc index 87eda069d50..1cdb0f09a81 100644 --- a/src/mgr/BaseMgrModule.cc +++ b/src/mgr/BaseMgrModule.cc @@ -483,7 +483,9 @@ ceph_store_set(BaseMgrModule *self, PyObject *args) if (value) { val = value; } + PyThreadState *tstate = PyEval_SaveThread(); self->py_modules->set_store(self->this_module->get_name(), key, val); + PyEval_RestoreThread(tstate); Py_RETURN_NONE; }