[1.5 critical] Branch.lock() does not set RemoteRepository.is_locked() == True
John Arbash Meinel
john at arbash-meinel.com
Fri May 9 18:25:01 BST 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Russ Brown wrote:
...
| I'm trying to track down why, but it seems to be causing some
| performance issues
| with remote operations that are using get_parent_map(). Because if the
| remote
| repo doesn't think it is locked, it will not cache any of the
| requests. And
| other stuff just plain breaks (bzr log --short bzr+ssh://, fails during
| iter_reverse_revision_history() because it thinks the repo isn't locked.)
|
|
|> In case it helps, I can reproduce this behaviour using 1.4 on both
|> client and server.
Thanks, it does help. I believe we have had this bug for a while. We haven't
noticed because we had more code going through Branch._ensure_real(). Specifically:
|>> b = bzrlib.branch.Branch.open('bzr+ssh:///')
|>> b.lock_read()
|>> print b.is_locked(), b.repository.is_locked()
True, False
|>> b._ensure_real()
|>> print b.is_locked(), b.repository.is_locked()
True, True
|>> b.unlock()
|>> print b.is_locked(), b.repository.is_locked()
False, False
|>> b.lock_read()
|>> print b.is_locked(), b.repository.is_locked()
True, True
Once we have b._real_branch, then the repo locking works as expected.
I think a possible patch would be:
=== modified file 'bzrlib/remote.py'
- --- bzrlib/remote.py 2008-05-08 04:33:38 +0000
+++ bzrlib/remote.py 2008-05-09 17:22:26 +0000
@@ -1293,6 +1293,10 @@
~ self._lock_count = 1
~ if self._real_branch is not None:
~ self._real_branch.lock_read()
+ else:
+ # If we have a _real_branch it will handle locking the
+ # repository, but without one, we need to do it ourself.
+ self.repository.lock_read()
~ else:
~ self._lock_count += 1
As I mentioned, though, this could easily result in the repository being left
locked if you did:
b.lock_read(); b._ensure_real(); b.unlock()
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkgkiO0ACgkQJdeBCYSNAAMrMwCfc/AqQJJyaD7IgLoQJ2tzj0Tx
wZ4AoJ8jNE6AiihxKFkWlAW0EQGYVIEC
=Ijvt
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list