Comment 0 for bug 1458718

Revision history for this message
Gong Zhang (zhanggbj) wrote : DB2 error occurs when neutron server enables multiple api works

When neutron server enables multiple api workers, it will use os.fork to start multiple neutron server process. During this period, some DB2 error will occur as below, which shows we are trying to close a closed connection. It seems like that pooled connection is shared by processes.

2015-04-29 22:27:39.330 567 ERROR sqlalchemy.pool.QueuePool [-] Exception closing connection <ibm_db_dbi.Connection object at 0x469a190>
2015-04-29 22:27:39.330 567 TRACE sqlalchemy.pool.QueuePool Traceback (most recent call last):
2015-04-29 22:27:39.330 567 TRACE sqlalchemy.pool.QueuePool File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 250, in _close_connection
2015-04-29 22:27:39.330 567 TRACE sqlalchemy.pool.QueuePool self._dialect.do_close(connection)
2015-04-29 22:27:39.330 567 TRACE sqlalchemy.pool.QueuePool File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 412, in do_close
2015-04-29 22:27:39.330 567 TRACE sqlalchemy.pool.QueuePool dbapi_connection.close()
2015-04-29 22:27:39.330 567 TRACE sqlalchemy.pool.QueuePool File "/usr/lib64/python2.7/site-packages/ibm_db_dbi.py", line 688, in close
2015-04-29 22:27:39.330 567 TRACE sqlalchemy.pool.QueuePool raise _get_exception(inst)
2015-04-29 22:27:39.330 567 TRACE sqlalchemy.pool.QueuePool OperationalError: ibm_db_dbi::OperationalError: [IBM][CLI Driver] CLI0106E Connection is closed. SQLSTATE=08003 SQLCODE=-99999

Currently neutron is using dispose() in child process to release the connnection and create new one. Actually we should close connection is father process before os.fork and create a separate engine for each child process.

Reference to sqlalchemy doc(http://docs.sqlalchemy.org/en/latest/core/connections.html#basic-usage)