Merge lp:~cmiller/ubuntu/lucid/desktopcouch/lp726597 into lp:ubuntu/lucid-proposed/desktopcouch

Proposed by Chad Miller
Status: Merged
Merged at revision: 23
Proposed branch: lp:~cmiller/ubuntu/lucid/desktopcouch/lp726597
Merge into: lp:ubuntu/lucid-proposed/desktopcouch
Diff against target: 85 lines (+73/-0)
2 files modified
debian/changelog (+7/-0)
debian/patches/lp_726597.patch (+66/-0)
To merge this branch: bzr merge lp:~cmiller/ubuntu/lucid/desktopcouch/lp726597
Reviewer Review Type Date Requested Status
Ubuntu Stable Release Updates Team Pending
Ubuntu Development Team Pending
Review via email: mp+52897@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2010-09-19 20:18:04 +0000
3+++ debian/changelog 2011-03-10 18:17:44 +0000
4@@ -1,3 +1,10 @@
5+desktopcouch (0.6.4-0ubuntu3.2) lucid-proposed; urgency=low
6+
7+ * Add debian/patches/lp_726597.patch
8+ - Avoid race for startup of couchdb (LP: #726597)
9+
10+ -- Chad MILLER <chad.miller@canonical.com> Thu, 03 Mar 2011 11:06:01 -0500
11+
12 desktopcouch (0.6.4-0ubuntu3.1) lucid-proposed; urgency=low
13
14 * Add gnome-keyring to depends of python-desktopcouch (LP: #565376)
15
16=== added file 'debian/patches/lp_726597.patch'
17--- debian/patches/lp_726597.patch 1970-01-01 00:00:00 +0000
18+++ debian/patches/lp_726597.patch 2011-03-10 18:17:44 +0000
19@@ -0,0 +1,66 @@
20+Description: Avoid a race to find and start a new couchdb.
21+Origin: Upstream
22+Author: Roman Yepishev <roman.yepishev@canonical.com>
23+Bug-Ubuntu: https://bugs.launchpad.net/726597
24+Forwarded: not-needed
25+
26+=== modified file 'desktopcouch/__init__.py'
27+--- old/desktopcouch/__init__.py 2010-03-10 22:18:24 +0000
28++++ new/desktopcouch/__init__.py 2011-02-23 22:58:49 +0000
29+@@ -20,7 +20,8 @@
30+ from desktopcouch.start_local_couchdb import process_is_couchdb, read_pidfile
31+ import dbus
32+ import logging
33+-
34++import time
35++from fcntl import flock, LOCK_EX, LOCK_NB
36+
37+ def find_pid(start_if_not_running=True, ctx=local_files.DEFAULT_CONTEXT):
38+ """Find the current OS process ID of the running couchdb. API users
39+@@ -30,11 +31,26 @@
40+ if not process_is_couchdb(pid):
41+ if start_if_not_running:
42+ # start CouchDB by running the startup script
43+- logging.info("Desktop CouchDB is not running; starting it.")
44+- from desktopcouch import start_local_couchdb
45+- pid = start_local_couchdb.start_couchdb(ctx=ctx)
46+- # now load the design documents, because it's started
47+- start_local_couchdb.update_design_documents()
48++ # we check the lock, if some process holds the lock then we will
49++ # merely wait for pifile to become meaningful
50++ try:
51++ ctx.lock_fd = open(ctx.file_lock, "w")
52++ flock(ctx.lock_fd, LOCK_EX | LOCK_NB)
53++ except IOError:
54++ logging.info("Another Desktop CouchDB is running. "
55++ "Waiting for PID.")
56++ pid = None
57++ for timeout in (0.4, 0.1, 0.1, 0.2, 0.5, 1, 3, 5):
58++ pid = read_pidfile(ctx=ctx)
59++ if pid is not None and process_is_couchdb(pid):
60++ break
61++ time.sleep(timeout)
62++ else:
63++ logging.info("Desktop CouchDB is not running; starting it.")
64++ from desktopcouch import start_local_couchdb
65++ pid = start_local_couchdb.start_couchdb(ctx=ctx)
66++ # now load the design documents, because it's started
67++ start_local_couchdb.update_design_documents()
68+
69+ if not process_is_couchdb(pid):
70+ logging.error("CouchDB process did not start up")
71+
72+=== modified file 'desktopcouch/local_files.py'
73+--- old/desktopcouch/local_files.py 2010-04-13 00:33:23 +0000
74++++ new/desktopcouch/local_files.py 2011-02-23 22:58:49 +0000
75+@@ -228,6 +228,9 @@
76+ self.file_stdout = os.path.join(run_dir, "desktop-couchdb.stdout")
77+ self.file_stderr = os.path.join(run_dir, "desktop-couchdb.stderr")
78+
79++ self.file_lock = os.path.join(run_dir, "desktop-couchdb.lock")
80++ self.lock_fd = None
81++
82+ # You will need to add -b or -k on the end of this
83+ self.couch_exec_command = [COUCH_EXE, self.couch_chain_ini_files(),
84+ '-p', self.file_pid,
85+

Subscribers

People subscribed via source and target branches

to all changes: