Merge lp:~rockstar/tarmac/lock-issues into lp:tarmac

Proposed by Paul Hummer
Status: Merged
Approved by: Paul Hummer
Approved revision: 399
Merged at revision: 406
Proposed branch: lp:~rockstar/tarmac/lock-issues
Merge into: lp:tarmac
Diff against target: 104 lines (+44/-37)
1 file modified
tarmac/branch.py (+44/-37)
To merge this branch: bzr merge lp:~rockstar/tarmac/lock-issues
Reviewer Review Type Date Requested Status
dobey Approve
Review via email: mp+95287@code.launchpad.net

Commit message

Wrap branch and tree locks in a finally to guarantee the .unlock will be called

Description of the change

This solution is *pretty* naive, but I thought I'd give it a shot (and it's a good idea anyway). I wrapped all the .lock() calls in a try: block with the unlock in a finally: block. This may or may not fix the segfault problem in our current tarmac, but it's worth a shot, and might be an easy win, rather than having to set up some really complicated test environment to reproduce. *shrug*

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

I don't think this code is where the problem is with the tarmac we have set up for ubuntuone. It is a fork with a patch I was working on, to add more extensive locking to deal with the multiple tarmac instances getting run, cases. I asked sidnei to link me to a couple logs where I could more explicitly where it was failing. We really need to properly fix the locking in tarmac though, as calling bzr_branch.lock_read() and such is incorrect. bzrlib should be holding the branch locked the entire time we're using it, but the way we're using bzr branches sort of breaks the way that works.

I'm going to vote Disapprove on this branch, because I'm like 10^1000% sure that the issue we're seeing, is not in these calls. Rather it's almost certainly happening in the command.py which is patched in the running instance, to keep the branch locked the entire time tarmac is dealing with that specific branch, so that other instances, or people, don't step on its feet while tests are running for a branch or something. We can discuss more on IRC tomorrow.

review: Disapprove
Revision history for this message
dobey (dobey) wrote :

So, based on our conversation in IRC, I don't disapprove of this branch on principle, as it's technically the correct thing to do with the code in trunk. I do think it might play a bit of potential havoc with the patch we're running tarmac with, which does locking/unlocking of the branch in the command.py code. But we can land this if you feel it's necessary, and poke about at fixing the locking properly, by refactoring the branch code.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tarmac/branch.py'
2--- tarmac/branch.py 2010-10-22 17:59:26 +0000
3+++ tarmac/branch.py 2012-02-29 23:21:34 +0000
4@@ -113,10 +113,13 @@
5 @property
6 def unmanaged_files(self):
7 """Get the list of ignored and unknown files in the tree."""
8- self.tree.lock_read()
9- unmanaged = [x for x in self.tree.unknowns()]
10- unmanaged.extend([x[0] for x in self.tree.ignored_files()])
11- self.tree.unlock()
12+ unmanaged = []
13+ try:
14+ self.tree.lock_read()
15+ unmanaged = [x for x in self.tree.unknowns()]
16+ unmanaged.extend([x[0] for x in self.tree.ignored_files()])
17+ finally:
18+ self.tree.unlock()
19 return unmanaged
20
21 @property
22@@ -160,26 +163,28 @@
23 author_list = []
24
25 if self.target:
26- self.bzr_branch.lock_read()
27- self.target.bzr_branch.lock_read()
28-
29- graph = self.bzr_branch.repository.get_graph(
30- self.target.bzr_branch.repository)
31-
32- unique_ids = graph.find_unique_ancestors(
33- self.bzr_branch.last_revision(),
34- [self.target.bzr_branch.last_revision()])
35-
36- revs = self.bzr_branch.repository.get_revisions(unique_ids)
37- for rev in revs:
38- apparent_authors = rev.get_apparent_authors()
39- for author in apparent_authors:
40- author.replace('\n', '')
41- if author not in author_list:
42- author_list.append(author)
43-
44- self.target.bzr_branch.unlock()
45- self.bzr_branch.unlock()
46+ try:
47+ self.bzr_branch.lock_read()
48+ self.target.bzr_branch.lock_read()
49+
50+ graph = self.bzr_branch.repository.get_graph(
51+ self.target.bzr_branch.repository)
52+
53+ unique_ids = graph.find_unique_ancestors(
54+ self.bzr_branch.last_revision(),
55+ [self.target.bzr_branch.last_revision()])
56+
57+ revs = self.bzr_branch.repository.get_revisions(unique_ids)
58+ for rev in revs:
59+ apparent_authors = rev.get_apparent_authors()
60+ for author in apparent_authors:
61+ author.replace('\n', '')
62+ if author not in author_list:
63+ author_list.append(author)
64+
65+ finally:
66+ self.target.bzr_branch.unlock()
67+ self.bzr_branch.unlock()
68 else:
69 last_rev = self.bzr_branch.last_revision()
70 if last_rev != 'null:':
71@@ -195,18 +200,20 @@
72 """Return the list of bugs fixed by the branch."""
73 bugs_list = []
74
75- self.bzr_branch.lock_read()
76- oldrevid = self.bzr_branch.get_rev_id(self.lp_branch.revision_count)
77- for rev_info in self.bzr_branch.iter_merge_sorted_revisions(
78- stop_revision_id=oldrevid):
79- try:
80- rev = self.bzr_branch.repository.get_revision(rev_info[0])
81- for bug in rev.iter_bugs():
82- if bug[0].startswith('https://launchpad.net/bugs/'):
83- bugs_list.append(bug[0].replace(
84- 'https://launchpad.net/bugs/', ''))
85- except NoSuchRevision:
86- continue
87+ try:
88+ self.bzr_branch.lock_read()
89+ oldrevid = self.bzr_branch.get_rev_id(self.lp_branch.revision_count)
90+ for rev_info in self.bzr_branch.iter_merge_sorted_revisions(
91+ stop_revision_id=oldrevid):
92+ try:
93+ rev = self.bzr_branch.repository.get_revision(rev_info[0])
94+ for bug in rev.iter_bugs():
95+ if bug[0].startswith('https://launchpad.net/bugs/'):
96+ bugs_list.append(bug[0].replace(
97+ 'https://launchpad.net/bugs/', ''))
98+ except NoSuchRevision:
99+ continue
100
101- self.bzr_branch.unlock()
102+ finally:
103+ self.bzr_branch.unlock()
104 return bugs_list

Subscribers

People subscribed via source and target branches