Merge lp:~osomon/software-center/fixDatabaseLockError into lp:software-center

Proposed by Olivier Tilloy
Status: Merged
Merged at revision: 1540
Proposed branch: lp:~osomon/software-center/fixDatabaseLockError
Merge into: lp:software-center
Diff against target: 18 lines (+7/-1)
1 file modified
utils/update-software-center-agent (+7/-1)
To merge this branch: bzr merge lp:~osomon/software-center/fixDatabaseLockError
Reviewer Review Type Date Requested Status
Michael Vogt Approve
Review via email: mp+50791@code.launchpad.net

Description of the change

This branch fixes bug #625189 and its many duplicates.

Previously, if two instances of update-software-center-agent were running concurrently, one of them would crash when trying to acquire a write lock on the temporary DB file. With this fix, the second instance will simply exit cleanly with a warning.

Testing is relatively easy: just run two instances of update-software-center-agent simultaneously.

I’m not sure how end users would end up in this situation though: from what I understand, the only caller of update-software-center-agent is the constructor of SoftwareCenterApp, so that seems to indicate that two instance of S-C would be running simultaneously, which is not allowed…

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Many thanks!

review: Approve
Revision history for this message
Michael Vogt (mvo) wrote :

It might be that someone started s-c and exited quickly. Then started it again so (before the first update-software-center-agent would finish).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utils/update-software-center-agent'
2--- utils/update-software-center-agent 2011-02-08 17:24:29 +0000
3+++ utils/update-software-center-agent 2011-02-22 18:04:54 +0000
4@@ -72,7 +72,13 @@
5 sys.exit(1)
6
7 # get a writable DB
8- db = xapian.WritableDatabase(pathname, xapian.DB_CREATE_OR_OVERWRITE)
9+ try:
10+ db = xapian.WritableDatabase(pathname, xapian.DB_CREATE_OR_OVERWRITE)
11+ except xapian.DatabaseLockError:
12+ # Ref: http://launchpad.net/bugs/625189
13+ logging.warn("Another instance of the update agent already holds "
14+ "a write lock on %s" % pathname)
15+ sys.exit(1)
16
17 # the following requires a http connection, so we do it in a
18 # seperate database