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
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 2011-01-03 19:12:01 +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 2011-01-03 19:12:01 +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')