[MERGE][0.11] Waiting on locks

John Arbash Meinel john at arbash-meinel.com
Fri Aug 25 21:54:36 BST 2006

Recently there was a discussion that we should actually try to wait on a
remote lock, rather than immediately failing. I think Martin mentioned
that it should already be doing that, but experience said otherwise, and
looking closer, I can see why Martin might have thought that.

We have:

LockDir.attempt_lock() which actually attempts to lock the remote file,
and fails otherwise.
LockDir.wait_lock() Which will spin for a while, trying to obtain the
lock every X seconds for Y total seconds before failing.
LockDir.lock_write() which is what the LockableFiles calls.

The documentation on lock_write says:
    def lock_write(self):
        """Wait for and acquire the lock."""

So I think it was intended that lock_write() would call
'self.wait_lock()' rather than calling 'self.attempt_lock()'.

However, the default lock timeout of 5 minutes seems a little bit long.

If we wanted to be really nice, we would make it configurable per
branch, since we might expect to wait longer on some branches than
others. However, that brings up lots of layering issues. Since now we
need to pass that information from the Branch down into the
LockableFiles, which has to know that it is using a LockDir, since it
needs to use wait_lock() instead of lock_write().

To be slightly less helpful, we could make it globally configurable, but
I still feel that having LockDir instantiate a GlobalConfig() object, so
that it can figure out the default lock timeout is not optimal either.

Anyway, the attached patch just changes LockDir so that it defaults to
waiting on the lock, and reports to the user that it is doing so.

I'm planning on writing the follow up patch, for

To changes the doc string of LockContention, to mention 'bzr
break-lock'. Though I think I also want to pass in a little bit more
info, to make the error nice looking for the user.

This probably shouldn't be an 0.10 change.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: wait-on-lock.patch
Type: text/x-patch
Size: 13334 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060825/5f0e1290/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060825/5f0e1290/attachment.pgp 

More information about the bazaar mailing list