summaryrefslogtreecommitdiff
path: root/neutron/service.py
diff options
context:
space:
mode:
authorGong Zhang <zhanggbj@cn.ibm.com>2015-05-27 17:10:17 +0800
committerGong Zhang <zhanggbj@cn.ibm.com>2015-05-28 11:13:23 +0800
commit88e499d1c10eaae59546d9f16c9c9c262766de84 (patch)
treecc4fc7d51e58cf8b353ae4f6e9aaa3c6bac2bb5e /neutron/service.py
parent420ca31da23cfe9a49b128cbce2d0b7cd9388974 (diff)
downloadneutron-88e499d1c10eaae59546d9f16c9c9c262766de84.tar.gz
Move pool dispose() before os.fork
Currently pool dispose() is done after os.fork, but this will produce shared DB connections in child processes which may lead to DB errors. Move pool dispose() before os.fork. This will remove all existing connections in the parent process and child processes will create their own new ones. Change-Id: Ie36417a64f0eb39b53dad61517f834aec37bacfb Closes-Bug: 1458718
Diffstat (limited to 'neutron/service.py')
-rw-r--r--neutron/service.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/neutron/service.py b/neutron/service.py
index 4d8e9a8541..708882b731 100644
--- a/neutron/service.py
+++ b/neutron/service.py
@@ -117,10 +117,6 @@ class RpcWorker(object):
self._servers = []
def start(self):
- # We may have just forked from parent process. A quick disposal of the
- # existing sql connections avoids producing errors later when they are
- # discovered to be broken.
- session.dispose()
self._servers = self._plugin.start_rpc_listeners()
def wait(self):
@@ -157,6 +153,10 @@ def serve_rpc():
rpc.start()
return rpc
else:
+ # dispose the whole pool before os.fork, otherwise there will
+ # be shared DB connections in child processes which may cause
+ # DB errors.
+ session.dispose()
launcher = common_service.ProcessLauncher(wait_interval=1.0)
launcher.launch_service(rpc, workers=cfg.CONF.rpc_workers)
return launcher