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

Proposed by Ryan Lucio
Status: Merged
Approved by: Eric Day
Approved revision: 506
Merged at revision: 512
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
Eric Day Pending
Devin Carlen Pending
Review via email: mp+45064@code.launchpad.net

This proposal supersedes 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 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).

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

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

sql_idle_timeout flag is a reasonable addition

Revision history for this message
Devin Carlen (devcamcar) wrote : Posted in a previous version of this proposal

lgtm

review: Approve
Revision history for this message
Eric Day (eday) wrote : Posted in a previous version of this proposal

lgtm

review: Approve
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Posted in a previous version of this proposal

The attempt to merge lp:~rlucio/nova/lp690314 into lp:nova failed. Below is the output from the failed tests.

nova/db/sqlalchemy/session.py:39:58: W291 trailing whitespace
            _ENGINE = create_engine(FLAGS.sql_connection,
                                                         ^
    JCR: Trailing whitespace is superfluous.
    FBM: Except when it occurs as part of a blank line (i.e. the line is
         nothing but whitespace). According to Python docs[1] a line with only
         whitespace is considered a blank line, and is to be ignored. However,
         matching a blank line to its indentation level avoids mistakenly
         terminating a multi-line statement (e.g. class declaration) when
         pasting code into the standard Python interpreter.

         [1] http://docs.python.org/reference/lexical_analysis.html#blank-lines

    The warning returned varies on whether the line itself is blank, for easier
    filtering for those who want to indent their blank lines.

    Okay: spam(1)
    W291: spam(1)\s
    W293: class Foo(object):\n \n bang = 12
nova/db/sqlalchemy/session.py:40:73: W291 trailing whitespace
                                    pool_recycle=FLAGS.sql_idle_timeout,
                                                                        ^
    JCR: Trailing whitespace is superfluous.
    FBM: Except when it occurs as part of a blank line (i.e. the line is
         nothing but whitespace). According to Python docs[1] a line with only
         whitespace is considered a blank line, and is to be ignored. However,
         matching a blank line to its indentation level avoids mistakenly
         terminating a multi-line statement (e.g. class declaration) when
         pasting code into the standard Python interpreter.

         [1] http://docs.python.org/reference/lexical_analysis.html#blank-lines

    The warning returned varies on whether the line itself is blank, for easier
    filtering for those who want to indent their blank lines.

    Okay: spam(1)
    W291: spam(1)\s
    W293: class Foo(object):\n \n bang = 12

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'nova/db/sqlalchemy/session.py'
--- nova/db/sqlalchemy/session.py 2010-10-21 23:15:26 +0000
+++ nova/db/sqlalchemy/session.py 2011-01-03 19:12:01 +0000
@@ -36,7 +36,9 @@
36 global _MAKER36 global _MAKER
37 if not _MAKER:37 if not _MAKER:
38 if not _ENGINE:38 if not _ENGINE:
39 _ENGINE = create_engine(FLAGS.sql_connection, echo=False)39 _ENGINE = create_engine(FLAGS.sql_connection,
40 pool_recycle=FLAGS.sql_idle_timeout,
41 echo=False)
40 _MAKER = (sessionmaker(bind=_ENGINE,42 _MAKER = (sessionmaker(bind=_ENGINE,
41 autocommit=autocommit,43 autocommit=autocommit,
42 expire_on_commit=expire_on_commit))44 expire_on_commit=expire_on_commit))
4345
=== modified file 'nova/flags.py'
--- nova/flags.py 2010-12-27 19:45:57 +0000
+++ nova/flags.py 2011-01-03 19:12:01 +0000
@@ -263,6 +263,9 @@
263DEFINE_string('sql_connection',263DEFINE_string('sql_connection',
264 'sqlite:///$state_path/nova.sqlite',264 'sqlite:///$state_path/nova.sqlite',
265 'connection string for sql database')265 'connection string for sql database')
266DEFINE_string('sql_idle_timeout',
267 '3600',
268 'timeout for idle sql database connections')
266269
267DEFINE_string('compute_manager', 'nova.compute.manager.ComputeManager',270DEFINE_string('compute_manager', 'nova.compute.manager.ComputeManager',
268 'Manager for compute')271 'Manager for compute')