Merge lp:~rlucio/nova/lp690314 into lp:~hudson-openstack/nova/trunk

Proposed by Ryan Lucio
Status: Superseded
Proposed branch: lp:~rlucio/nova/lp690314
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 28 lines (+6/-1)
2 files modified
nova/db/sqlalchemy/session.py (+3/-1)
nova/flags.py (+3/-0)
To merge this branch: bzr merge lp:~rlucio/nova/lp690314
Reviewer Review Type Date Requested Status
Nova Core security contacts Pending
Review via email: mp+44883@code.launchpad.net

This proposal has been superseded by a proposal from 2010-12-31.

Description of the change

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 hardcoded. What this means is that if a db connection sits idle for an hour, the engine will automatically close the connection and return it to the available thread pool. See Bug #690314 for info.

WRT hardcoding the timeout, there is no indication (based on what I read) that there is any reason to use a different value. It was suggested by another dev that we should hard code 1800 but I am not aware of any advantage in that value.

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).

To post a comment you must log in.
Revision history for this message
Thierry Carrez (ttx) wrote :

3600 sounds like a sane default given most databases idle connection timeout... but I don't think we should hardcode it. Adding a flag to change that default value would allow us to cover all corner cases ?

Revision history for this message
Ryan Lucio (rlucio) wrote :

If you think it is necessary that is fine. How about a new flag, sql_idle_timeout that defaults to 3600?

Revision history for this message
Devin Carlen (devcamcar) wrote :

sql_idle_timeout flag is a reasonable addition

lp:~rlucio/nova/lp690314 updated
505. By Ryan Lucio

Converted the pool_recycle setting to be a flag with a default of 3600 seconds

506. By Ryan Lucio

removed extra whitespace chars at the end of the changed lines

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/db/sqlalchemy/session.py'
2--- nova/db/sqlalchemy/session.py 2010-10-21 23:15:26 +0000
3+++ nova/db/sqlalchemy/session.py 2010-12-31 00:24:09 +0000
4@@ -36,7 +36,9 @@
5 global _MAKER
6 if not _MAKER:
7 if not _ENGINE:
8- _ENGINE = create_engine(FLAGS.sql_connection, echo=False)
9+ _ENGINE = create_engine(FLAGS.sql_connection,
10+ pool_recycle=FLAGS.sql_idle_timeout,
11+ echo=False)
12 _MAKER = (sessionmaker(bind=_ENGINE,
13 autocommit=autocommit,
14 expire_on_commit=expire_on_commit))
15
16=== modified file 'nova/flags.py'
17--- nova/flags.py 2010-12-27 19:45:57 +0000
18+++ nova/flags.py 2010-12-31 00:24:09 +0000
19@@ -263,6 +263,9 @@
20 DEFINE_string('sql_connection',
21 'sqlite:///$state_path/nova.sqlite',
22 'connection string for sql database')
23+DEFINE_string('sql_idle_timeout',
24+ '3600',
25+ 'timeout for idle sql database connections')
26
27 DEFINE_string('compute_manager', 'nova.compute.manager.ComputeManager',
28 'Manager for compute')