Merge lp:~james-w/udd/sqlite-timeout into lp:udd

Proposed by James Westby
Status: Merged
Approved by: Max Bowsher
Approved revision: 573
Merged at revision: 573
Proposed branch: lp:~james-w/udd/sqlite-timeout
Merge into: lp:udd
Diff against target: 74 lines (+8/-6)
3 files modified
udd/icommon.py (+0/-1)
udd/idb.py (+4/-1)
udd/tests/test_idb.py (+4/-4)
To merge this branch: bzr merge lp:~james-w/udd/sqlite-timeout
Reviewer Review Type Date Requested Status
Max Bowsher (community) Approve
Review via email: mp+101317@code.launchpad.net

Description of the change

Hi,

This has the storm code use the sqlite timeout that was in use when
using sqlite3. Hopefully this will avoid most of the db contention errors
we have been seeing.

Thanks,

James

To post a comment you must log in.
Revision history for this message
Max Bowsher (maxb) wrote :

Makes sense, doesn't introduce any new test failures. Most definitely required, given the errors happening on jubany.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'udd/icommon.py'
2--- udd/icommon.py 2012-04-04 17:32:38 +0000
3+++ udd/icommon.py 2012-04-10 01:20:26 +0000
4@@ -42,7 +42,6 @@
5 # below. Some way to share the config is needed -- vila 2011-12-07
6 conf = iconfig.ImporterStack()
7
8-sqlite_timeout = 30
9 running_sentinel = "Apparently the supervisor died\n"
10 no_lock_returncode = 139
11
12
13=== modified file 'udd/idb.py'
14--- udd/idb.py 2012-03-23 17:14:07 +0000
15+++ udd/idb.py 2012-04-10 01:20:26 +0000
16@@ -1,6 +1,9 @@
17 from storm.locals import create_database, Store
18
19
20+sqlite_timeout = 30
21+
22+
23 def get_sqlite_connection_string(config, db_name):
24 if db_name == 'main':
25 path = config.get('pi.sqlite_file')
26@@ -10,7 +13,7 @@
27 path = config.get('pi.sqlite_history_file')
28 else:
29 raise AssertionError("Unknown db_name: %s" % db_name)
30- return 'sqlite:%s' % path
31+ return 'sqlite:%s?timeout=%d' % (path, sqlite_timeout)
32
33
34 def get_postgres_connection_string(config, db_name):
35
36=== modified file 'udd/tests/test_idb.py'
37--- udd/tests/test_idb.py 2012-03-23 17:14:07 +0000
38+++ udd/tests/test_idb.py 2012-04-10 01:20:26 +0000
39@@ -12,7 +12,7 @@
40 iconfig.PkgimportStore(self.get_transport()),
41 'pi.sqlite_file=bar\n')
42 stack = iconfig.ImporterStack()
43- self.assertEquals('sqlite:bar',
44+ self.assertEquals('sqlite:bar?timeout=%d' % idb.sqlite_timeout,
45 idb.get_sqlite_connection_string(stack, 'main'))
46
47 def test_get_sqlite_connection_string_package(self):
48@@ -20,7 +20,7 @@
49 iconfig.PkgimportStore(self.get_transport()),
50 'pi.sqlite_package_file=baz\n')
51 stack = iconfig.ImporterStack()
52- self.assertEquals('sqlite:baz',
53+ self.assertEquals('sqlite:baz?timeout=%d' % idb.sqlite_timeout,
54 idb.get_sqlite_connection_string(stack, 'package'))
55
56 def test_get_sqlite_connection_string_history(self):
57@@ -28,7 +28,7 @@
58 iconfig.PkgimportStore(self.get_transport()),
59 'pi.sqlite_history_file=zap\n')
60 stack = iconfig.ImporterStack()
61- self.assertEquals('sqlite:zap',
62+ self.assertEquals('sqlite:zap?timeout=%d' % idb.sqlite_timeout,
63 idb.get_sqlite_connection_string(stack, 'history'))
64
65
66@@ -57,7 +57,7 @@
67 'pi.db_type=sqlite\npi.sqlite_file=bar\n')
68 stack = iconfig.ImporterStack()
69 conn_str, db_type = idb.get_connection_string(stack, 'main')
70- self.assertEquals('sqlite:bar', conn_str)
71+ self.assertEquals('sqlite:bar?timeout=%d' % idb.sqlite_timeout, conn_str)
72 self.assertEquals('sqlite', db_type)
73
74 def test_get_connection_string_postgres(self):

Subscribers

People subscribed via source and target branches