Merge lp:~spiv/bzr/push-relock into lp:bzr
| Status: | Work in progress |
|---|---|
| Proposed branch: | lp:~spiv/bzr/push-relock |
| Merge into: | lp:bzr |
| Diff against target: |
102 lines (+28/-3) 4 files modified
NEWS (+3/-0) bzrlib/builtins.py (+2/-0) bzrlib/bzrdir.py (+3/-2) bzrlib/push.py (+20/-1) |
| To merge this branch: | bzr merge lp:~spiv/bzr/push-relock |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| bzr-core | 2010-04-20 | Pending | |
|
Review via email:
|
|||
Commit Message
Avoid relocking in cmd_push.
Description of the Change
This fixes more relock warnings, this time in cmd_push.
This one is a bit uglier than the previous patches: most of the time cmd_push just needs a read-lock on br_from (the source branch), but occasionally it wants to set the remembered push location. And sometimes it won't know that it will want to until after reading the branch.conf -- i.e. after the read-lock has been acquired.
Unfortunately, we don't have an API to upgrade a read lock to write lock, so instead this patch opens a separate instance of the (already read-locked) branch so it can write-lock that and set the push location. That second instance is then discarded. The downside, as explained in the comment, is that the read-locked version will not see the update, but in this case I don't think that matters.
| Robert Collins (lifeless) wrote : | # |
| Andrew Bennetts (spiv) wrote : | # |
Hmm. I see what you mean (about older formats). I suppose the thing to
do is to catch LockContention, and if it occurs emit a warning to the
user that the push location could not be set due lock contention, and
then let the rest of the code proceed as normal. I think even for older
formats that's probably an improvement in behaviour: I'd rather the
overall push worked immediately even if bzr can't remember the location
because the branch is locked.
I'd love an API to upgrade to a write lock — and I think we'll need one
if we ever decide to pursue a zero relocks as a goal. But it looks like
a moderately large chunk of work. Maybe I'm wrong?
| John A Meinel (jameinel) wrote : | # |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Andrew Bennetts wrote:
> Hmm. I see what you mean (about older formats). I suppose the thing to
> do is to catch LockContention, and if it occurs emit a warning to the
> user that the push location could not be set due lock contention, and
> then let the rest of the code proceed as normal. I think even for older
> formats that's probably an improvement in behaviour: I'd rather the
> overall push worked immediately even if bzr can't remember the location
> because the branch is locked.
>
> I'd love an API to upgrade to a write lock — and I think we'll need one
> if we ever decide to pursue a zero relocks as a goal. But it looks like
> a moderately large chunk of work. Maybe I'm wrong?
Well, we already have *some* of that in the code today. Because Dirstate
can be updated within a logical 'read' lock. (status updating the hash
cache). So it has some "try to switch to a write lock" code.
I don't know what that would imply for something like Branch, though.
For Repository, it is trivial, because a write-lock is *still* a no-op
until you 'commit_
something to write-lock, though.
And we'd also need to decide what to do when the write-lock is already
taken.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://
iEYEARECAAYFAkv
MRUAnR+
=wyUS
-----END PGP SIGNATURE-----
Unmerged revisions
- 5148. By Andrew Bennetts on 2010-04-20
-
Tweak NEWS entry wording for consistency.
- 5147. By Andrew Bennetts on 2010-04-20
-
Merge lp:bzr.
- 5146. By Andrew Bennetts on 2010-04-20
-
Add NEWS entry.
- 5145. By Andrew Bennetts on 2010-04-12
-
Try to avoid relocking in cmd_push using an ugly hack for the --remember case.

This won't work with older bzr formats that use a mutex across all processes
on write locks. I don't know if that matters, but it should be at least
documented, I think. Other than that it seems that perhaps its worth doing
an api to upgrade to a write lock?