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
=== modified file 'utils/update-software-center-agent'
--- utils/update-software-center-agent 2011-02-08 17:24:29 +0000
+++ utils/update-software-center-agent 2011-02-22 18:04:54 +0000
@@ -72,7 +72,13 @@
72 sys.exit(1)72 sys.exit(1)
7373
74 # get a writable DB74 # get a writable DB
75 db = xapian.WritableDatabase(pathname, xapian.DB_CREATE_OR_OVERWRITE)75 try:
76 db = xapian.WritableDatabase(pathname, xapian.DB_CREATE_OR_OVERWRITE)
77 except xapian.DatabaseLockError:
78 # Ref: http://launchpad.net/bugs/625189
79 logging.warn("Another instance of the update agent already holds "
80 "a write lock on %s" % pathname)
81 sys.exit(1)
7682
77 # the following requires a http connection, so we do it in a 83 # the following requires a http connection, so we do it in a
78 # seperate database84 # seperate database