summaryrefslogtreecommitdiffstats
path: root/nova/db
diff options
context:
space:
mode:
authorRyan Lucio <rlucio@internap.com>2011-01-03 19:49:45 +0000
committerTarmac <>2011-01-03 19:49:45 +0000
commit6fc9fdc57cc0c516feec36f594a1fb8460c1c8e0 (patch)
tree77ec8af4620b76c94f881a6183ff0ba6275d3037 /nova/db
parent3a54315765861bb883e15c00623752d32560de54 (diff)
parent5fd9ff898bf372f26bac3c0530521ba7abb7f26c (diff)
downloadnova-6fc9fdc57cc0c516feec36f594a1fb8460c1c8e0.tar.gz
nova-6fc9fdc57cc0c516feec36f594a1fb8460c1c8e0.tar.xz
nova-6fc9fdc57cc0c516feec36f594a1fb8460c1c8e0.zip
Adds the pool_recycle option to the sql engine startup call. This enables connection auto-timeout so that connection pooling will work properly. The recommended setting (per sqlalchemy FAQ page) has been provided as a default for a new configuration flag. What this means is that if a db connection sits idle for the configured # of seconds, the engine will automatically close the connection and return it to the available thread pool. See Bug #690314 for info.
The fix was tested and verified on multi-node deployments of Austin and Bexar with MySQL, and it was also verified that the change does not affect sqlite users (dev environment testing only).
Diffstat (limited to 'nova/db')
-rw-r--r--nova/db/sqlalchemy/session.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/nova/db/sqlalchemy/session.py b/nova/db/sqlalchemy/session.py
index e0d84c107..c3876c02a 100644
--- a/nova/db/sqlalchemy/session.py
+++ b/nova/db/sqlalchemy/session.py
@@ -36,7 +36,9 @@ def get_session(autocommit=True, expire_on_commit=False):
global _MAKER
if not _MAKER:
if not _ENGINE:
- _ENGINE = create_engine(FLAGS.sql_connection, echo=False)
+ _ENGINE = create_engine(FLAGS.sql_connection,
+ pool_recycle=FLAGS.sql_idle_timeout,
+ echo=False)
_MAKER = (sessionmaker(bind=_ENGINE,
autocommit=autocommit,
expire_on_commit=expire_on_commit))