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: v14.1.0~920^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b09aefc2d6af3de8cc3df30258dfdc639c919a9f;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 --- diff --git a/src/pybind/mgr/restful/module.py b/src/pybind/mgr/restful/module.py index 5b55da92da5b..009425d22192 100644 --- a/src/pybind/mgr/restful/module.py +++ b/src/pybind/mgr/restful/module.py @@ -368,7 +368,8 @@ class Module(MgrModule): if tag == 'seq': return try: - request = next(x for x in self.requests if x.is_running(tag)) + with self.requests_lock: + request = next(x for x in self.requests if x.is_running(tag)) request.finish(tag) if request.is_ready(): request.next() @@ -583,8 +584,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():