Merge lp:~soren/nova/sqlite-locking into lp:~hudson-openstack/nova/trunk

Proposed by Soren Hansen on 2011-02-10
Status: Merged
Approved by: Devin Carlen on 2011-02-10
Approved revision: 662
Merged at revision: 661
Proposed branch: lp:~soren/nova/sqlite-locking
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 28 lines (+8/-2)
1 file modified
nova/db/sqlalchemy/session.py (+8/-2)
To merge this branch: bzr merge lp:~soren/nova/sqlite-locking
Reviewer Review Type Date Requested Status
Devin Carlen (community) Approve on 2011-02-10
Rick Harris (community) Approve on 2011-02-10
Jay Pipes (community) Approve on 2011-02-10
Vish Ishaya (community) 2011-02-10 Approve on 2011-02-10
Review via email: mp+49234@code.launchpad.net

Commit Message

Use a NullPool for sqlite connections.

Description of the Change

Since applying this I have not had a single lock timeout using sqlite. My test suite used to retry every API operation up to 20 times (admittedly, I think 10 would have sufficed in almost every case) to work around locking issues.

A NullPool simply connects/disconnects with every connection. No persistent connections are used at all.

To post a comment you must log in.
Vish Ishaya (vishvananda) wrote :

lgtm

review: Approve
Jay Pipes (jaypipes) wrote :

cool. looks good.

review: Approve
Rick Harris (rconradharris) wrote :

lgtm

review: Approve
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve

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 2011-01-21 23:48:10 +0000
3+++ nova/db/sqlalchemy/session.py 2011-02-10 14:43:55 +0000
4@@ -20,6 +20,7 @@
5 """
6
7 from sqlalchemy import create_engine
8+from sqlalchemy import pool
9 from sqlalchemy.orm import sessionmaker
10
11 from nova import exception
12@@ -37,9 +38,14 @@
13 global _MAKER
14 if not _MAKER:
15 if not _ENGINE:
16+ kwargs = {'pool_recycle': FLAGS.sql_idle_timeout,
17+ 'echo': False}
18+
19+ if FLAGS.sql_connection.startswith('sqlite'):
20+ kwargs['poolclass'] = pool.NullPool
21+
22 _ENGINE = create_engine(FLAGS.sql_connection,
23- pool_recycle=FLAGS.sql_idle_timeout,
24- echo=False)
25+ **kwargs)
26 _MAKER = (sessionmaker(bind=_ENGINE,
27 autocommit=autocommit,
28 expire_on_commit=expire_on_commit))