summaryrefslogtreecommitdiffstats
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
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).
-rw-r--r--nova/db/sqlalchemy/session.py4
-rw-r--r--nova/flags.py3
2 files changed, 6 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))
diff --git a/nova/flags.py b/nova/flags.py
index d773a7e4c..e872ba217 100644
--- a/nova/flags.py
+++ b/nova/flags.py
@@ -263,6 +263,9 @@ DEFINE_string('state_path', os.path.join(os.path.dirname(__file__), '../'),
DEFINE_string('sql_connection',
'sqlite:///$state_path/nova.sqlite',
'connection string for sql database')
+DEFINE_string('sql_idle_timeout',
+ '3600',
+ 'timeout for idle sql database connections')
DEFINE_string('compute_manager', 'nova.compute.manager.ComputeManager',
'Manager for compute')