From 6d7f6209b76f2d38ff832e556937510228d76bda Mon Sep 17 00:00:00 2001 From: Jerry Lee Date: Mon, 12 Nov 2018 14:27:53 +0800 Subject: [PATCH] ceph-mgr: hold lock while accessing the request list and submitting request The request creation can fire up the notify event early and it can cause a race condition where the actual request was not yet added to the self.requests list which makes the submit_request() function waits forever without accepting new requests. https://marc.info/?l=ceph-devel&m=154104291714160&w=2 Fixes: https://tracker.ceph.com/issues/36764 Signed-off-by: Jerry Lee (cherry picked from commit b09aefc2d6af3de8cc3df30258dfdc639c919a9f) Conflicts: src/pybind/mgr/restful/module.py --- src/pybind/mgr/restful/module.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/restful/module.py b/src/pybind/mgr/restful/module.py index a6c9c638fe247..6a4b1b6bf4405 100644 --- a/src/pybind/mgr/restful/module.py +++ b/src/pybind/mgr/restful/module.py @@ -365,7 +365,9 @@ class Module(MgrModule): if tag == 'seq': return - request = [x for x in self.requests if x.is_running(tag)] + with self.requests_lock: + request = [x for x in self.requests if x.is_running(tag)] + if len(request) != 1: self.log.warn("Unknown request '%s'" % str(tag)) return @@ -584,8 +586,8 @@ class Module(MgrModule): def submit_request(self, _request, **kwargs): - request = CommandsRequest(_request) with self.requests_lock: + request = CommandsRequest(_request) self.requests.append(request) if kwargs.get('wait', 0): while not request.is_finished(): -- 2.39.5