Configurable Wait-on-lock timeout.
John Arbash Meinel
john at arbash-meinel.com
Wed Sep 27 23:14:47 BST 2006
I just merged the changes to allow bzr to wait for locks to be released
before actually failing. This should be nicer for users.
There are 2 issues now.
1) There are a few tests in the test suite that wait for LockContention
to be raised. They need to change the default timeout time, so that they
don't wait 5min for each attempt. The attached patch implements this.
Also, in testing, I found a code path that wasn't using try/finally to
clean itself up.
I went ahead and merged this, because otherwise the test suite is pretty
bad. If we want to revert both patches, that is fine. But we shouldn't
have one without the other.
2) Long term, we probably want this configurable per branch/repo/tree?
They all make a request to LockDir.lock_write().
So right now, I changed lock_write() so that it calls wait_lock() rather
than attempt_lock(), because that makes the higher levels not have to
change.
I can change them to directly call wait_lock(), but for earlier branch
formats, we don't have a 'wait_lock()' for OS or sftp locks.
We also have some api layers hiding things. Because the locking is done
inside LockableFiles, which takes a lock_class argument. We can expand
it to take a timeout, or perhaps just general arguments to pass? But it
would also need to know whether to call self._lock.lock_write() or
self._lock.wait_lock(timeout=X, poll=Y).
We have a few alternatives too.
A) Make the default timeout part of the LockDir constructor. Then we
can pass LockableFiles extra parameters to pass when constructing
the lock, rather than doing it at the time we actually want to
lock.
B) We can extend LockableFiles so that it has a 'wait_lock()' function
which passes the values down to self._lock. And if no values are
passed it defaults to just calling lock_write(), rather than
calling wait_lock().
I'm just trying to find out what the best way is, to maintain
compatibility with existing code.
John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wait-on-lock-timeout.patch
Type: text/x-patch
Size: 10789 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060927/6f34ce87/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/20060927/6f34ce87/attachment.pgp
More information about the bazaar
mailing list