From: Jerry Lee Date: Mon, 12 Nov 2018 06:27:53 +0000 (+0800) Subject: ceph-mgr: hold lock while accessing the request list and submitting request X-Git-Tag: v13.2.3~31^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6d7f6209b76f2d38ff832e556937510228d76bda;p=ceph.git 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 --- diff --git a/src/pybind/mgr/restful/module.py b/src/pybind/mgr/restful/module.py index a6c9c638fe24..6a4b1b6bf440 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():