[BUG] Hidden bug in `bzr info` when dirstate tree is write-locked
Alexander Belchenko
bialix at ukr.net
Tue Apr 17 11:36:49 BST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
(OS locks drive me crazy)
There is the hidden bug in `info` command and in
blackbox.test_info.TestInfo.test_info_locking test as well.
This test try to check if output of `bzr info` is valid
for all combination of locked repo/breanch/tree.
But in this test `bzr info` is not launched as subprocess.
It's important. And this fact has one BIG side effect,
that hide real problem with OS locks.
On Linux this test does not fail, so I assume
on Linux you can get write lock and then get read lock
from the same process (it's important!).
Because test write-locks the tree and then invoke self.run_bzr('info').
There is such code in info.py to read the status of tree:
try:
working = a_bzrdir.open_workingtree(
recommend_upgrade=False)
working.lock_read()
try:
show_tree_info(working, verbose)
finally:
working.unlock()
return
except (NoWorkingTree, NotLocalUrl):
pass
I.e. `info` command try to obtain read lock for (possibly) write-locked
tree. And this attempt is successful for the same process on Linux.
As you can see there is no special guard for possible LockContention error
in statement working.lock_read().
But on Windows this test fails, because write lock is exclusive.
And write lock is also exclusive for different processes even on Linux.
To reproduce error in `bzr info` you need to do following.
In first terminal window:
$ bzr init
$ bzr mkdir dir
$ bzr ci
^-- at this point hold editor open to keep write lock.
In second terminal window:
$ bzr info
bzr: ERROR: Could not acquire lock [Errno 11] Resource temporarily unavailable
/tmp/bzr/bzr.dev/bzrlib/lock.py:79: UserWarning: lock on <open file
u'/home/bialix/1/.bzr/checkout/dirstate', mode 'rb' at 0x40875c80> not released
warn("lock on %r not released" % self.f)
Voilà.
[µ]
- --
/me really tired to fight against OS locks.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGJKNBzYr338mxwCURAnfgAJ0SMMxd3EeN4H2h+YobsA7CCG2yowCeMeVX
40QGRnaBDEpRzFJcCj2CsKM=
=YJBj
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list