Merge lp:~spiv/bzr/hpss-diff-locking-bug into lp:bzr/2.0

Proposed by Andrew Bennetts
Status: Merged
Merged at revision: not available
Proposed branch: lp:~spiv/bzr/hpss-diff-locking-bug
Merge into: lp:bzr/2.0
Diff against target: 55 lines
3 files modified
NEWS (+3/-0)
bzrlib/remote.py (+1/-0)
bzrlib/tests/test_remote.py (+20/-0)
To merge this branch: bzr merge lp:~spiv/bzr/hpss-diff-locking-bug
Reviewer Review Type Date Requested Status
Vincent Ladeuil Approve
Review via email: mp+12965@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Andrew Bennetts (spiv) wrote :

This fixes bug 389413. Various code paths assume that Branch.get_rev_id will implicitly lock_read the branch (and repository), but RemoteBranch's get_rev_id didn't have the @needs_read_lock decorator. So this branch fixes that, and adds a test about it. The sneaky part is that RemoteBranch would get away with it if the server is new enough, which is probably why the existing test suite didn't catch this.

Also, it's not so great that callers such as revisionspec.py expect get_rev_id to acquire a read lock for them, as we are almost certainly wasting some effort, but fixing the performance is separate to fixing the correctness. (And fixing the performance is considerable knottier.)

I think this fix is a good candidate for the 2.0 branch.

Revision history for this message
Vincent Ladeuil (vila) wrote :

Clear, concise, nice job :)
I agree that should be backported to 2.0.x.

review: Approve
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Vincent Ladeuil wrote:
> Review: Approve
> Clear, concise, nice job :)
> I agree that should be backported to 2.0.x.

Overall, I would like to see us get away from @needs_read_lock
decorators, because they inherently hide performance issues.

That said, good enough for a bugfix, I guess.

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrMmIQACgkQJdeBCYSNAANJbgCgwHUcc3Xwb/ReidSTi3fF8xPL
J7EAnjNf4uixV+lKLkqKtk4KXvtzrGWI
=ARY2
-----END PGP SIGNATURE-----

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2009-10-07 00:46:40 +0000
+++ NEWS 2009-10-07 05:45:22 +0000
@@ -26,6 +26,9 @@
26 with some combinations of remote and local formats. This was causing26 with some combinations of remote and local formats. This was causing
27 "unknown object type identifier 60" errors. (Andrew Bennetts, #427736)27 "unknown object type identifier 60" errors. (Andrew Bennetts, #427736)
2828
29* Fixed ``ObjectNotLocked`` errors when doing some log and diff operations
30 on branches via a smart server. (Andrew Bennetts, #389413)
31
29* Occasional IndexError on renamed files have been fixed. Operations that32* Occasional IndexError on renamed files have been fixed. Operations that
30 set a full inventory in the working tree will now go via the33 set a full inventory in the working tree will now go via the
31 apply_inventory_delta code path which is simpler and easier to34 apply_inventory_delta code path which is simpler and easier to
3235
=== modified file 'bzrlib/remote.py'
--- bzrlib/remote.py 2009-10-02 03:07:22 +0000
+++ bzrlib/remote.py 2009-10-07 05:45:22 +0000
@@ -2392,6 +2392,7 @@
2392 raise NotImplementedError(self.dont_leave_lock_in_place)2392 raise NotImplementedError(self.dont_leave_lock_in_place)
2393 self._leave_lock = False2393 self._leave_lock = False
23942394
2395 @needs_read_lock
2395 def get_rev_id(self, revno, history=None):2396 def get_rev_id(self, revno, history=None):
2396 if revno == 0:2397 if revno == 0:
2397 return _mod_revision.NULL_REVISION2398 return _mod_revision.NULL_REVISION
23982399
=== modified file 'bzrlib/tests/test_remote.py'
--- bzrlib/tests/test_remote.py 2009-09-10 06:32:42 +0000
+++ bzrlib/tests/test_remote.py 2009-10-07 05:45:22 +0000
@@ -2147,6 +2147,26 @@
2147 repo.get_rev_id_for_revno, 5, (42, 'rev-foo'))2147 repo.get_rev_id_for_revno, 5, (42, 'rev-foo'))
2148 self.assertFinished(client)2148 self.assertFinished(client)
21492149
2150 def test_branch_fallback_locking(self):
2151 """RemoteBranch.get_rev_id takes a read lock, and tries to call the
2152 get_rev_id_for_revno verb. If the verb is unknown the VFS fallback
2153 will be invoked, which will fail if the repo is unlocked.
2154 """
2155 self.setup_smart_server_with_call_log()
2156 tree = self.make_branch_and_memory_tree('.')
2157 tree.lock_write()
2158 rev1 = tree.commit('First')
2159 rev2 = tree.commit('Second')
2160 tree.unlock()
2161 branch = tree.branch
2162 self.assertFalse(branch.is_locked())
2163 self.reset_smart_call_log()
2164 verb = 'Repository.get_rev_id_for_revno'
2165 self.disable_verb(verb)
2166 self.assertEqual(rev1, branch.get_rev_id(1))
2167 self.assertLength(1, [call for call in self.hpss_calls if
2168 call.call.method == verb])
2169
21502170
2151class TestRepositoryIsShared(TestRemoteRepository):2171class TestRepositoryIsShared(TestRemoteRepository):
21522172

Subscribers

People subscribed via source and target branches