OS locks woes (was: Re: [MERGE] Implement bzrlib.lock with CreateFile rather than LockFileEx on win32 (operational part))

Alexander Belchenko bialix at ukr.net
Fri Jun 19 10:30:34 BST 2009


Using this patch from Martin (gzlist) and some small change to the code 
to print filename of OS-locked file (I've did it for testing unicode 
locking) and I found that dirstate locked toooo often in some situations.

May be our dear bzr.devs already know this, but -Dlock does not show 
this kind of info, so I show you my results. As you could see many 
operations lock the dirstate 3-4 and more times. I don't think it's 
right, especially regarding to various OS locks problem on Windows.

C:\Temp\Тест>python C:\work\Bazaar\bzr-repo\lock\bzr --no-plugins st
C:/Temp/Тест/.bzr/checkout/dirstate
C:/Temp/Тест/.bzr/checkout/dirstate
C:/Temp/Тест/.bzr/checkout/dirstate

C:\work\Bazaar\bzr-repo\lock>python C:\work\Bazaar\bzr-repo\lock\bzr 
-Dlock --no-plugins st
C:/work/Bazaar/bzr-repo/lock/.bzr/checkout/dirstate
modified:
   bzrlib/lock.py
pending merge tips: (use -v to see all merge revisions)
   Martin 2009-06-18 Implement bzrlib.lock with CreateFile rather than 
LockFileEx on win32
C:/work/Bazaar/bzr-repo/lock/.bzr/checkout/dirstate
C:/work/Bazaar/bzr-repo/lock/.bzr/checkout/dirstate

C:\Temp\Тест>python C:\work\Bazaar\bzr-repo\lock\bzr -Dlock --no-plugins 
mkdir bar
C:/Temp/Тест/.bzr/checkout/dirstate
added bar

C:\Temp\Тест>python C:\work\Bazaar\bzr-repo\lock\bzr -Dlock --no-plugins st
C:/Temp/Тест/.bzr/checkout/dirstate
added:
   bar/
C:/Temp/Тест/.bzr/checkout/dirstate
C:/Temp/Тест/.bzr/checkout/dirstate

C:\Temp\Тест>python C:\work\Bazaar\bzr-repo\lock\bzr -Dlock --no-plugins 
diff
C:/Temp/Тест/.bzr/checkout/dirstate
C:/Temp/Тест/.bzr/checkout/dirstate
C:/Temp/Тест/.bzr/checkout/dirstate
C:/Temp/Тест/.bzr/checkout/dirstate
=== added directory 'bar'

C:\Temp\Тест>python C:\work\Bazaar\bzr-repo\lock\bzr -Dlock --no-plugins 
ci -m2
C:/Temp/Тест/.bzr/checkout/dirstate
Committing to: C:/Temp/Тест/
added bar
Committed revision 2.

C:\Temp\Тест>python C:\work\Bazaar\bzr-repo\lock\bzr -Dlock --no-plugins 
push a-push
C:/Temp/Тест/.bzr/checkout/dirstate
C:/Temp/Тест/a-push/.bzr/checkout/dirstate
C:/Temp/Тест/a-push/.bzr/checkout/dirstate
C:/Temp/Тест/a-push/.bzr/checkout/dirstate
C:/Temp/Тест/a-push/.bzr/checkout/dirstate
C:/Temp/Тест/a-push/.bzr/checkout/dirstate
C:/Temp/Тест/a-push/.bzr/checkout/dirstate
C:/Temp/Тест/a-push/.bzr/checkout/dirstate
bzr: ERROR: Could not acquire lock 
"C:/Temp/╨в╨╡╤Б╤В/a-push/.bzr/checkout/dirstate": (32, 'CreateFile', 
'The process cannot acce
ss the file because it is being used by another process.')


As yopu could see 4 times locked for diff, and 7 (seven!) times locked 
for push!

What about this wonderful bug about shelve?

C:\Temp\Тест>python C:\work\Bazaar\bzr-repo\lock\bzr -Dlock --no-plugins add
C:/Temp/Тест/.bzr/checkout/dirstate
adding spam

C:\Temp\Тест>python C:\work\Bazaar\bzr-repo\lock\bzr -Dlock --no-plugins 
shelve
C:/Temp/Тест/.bzr/checkout/dirstate
C:/Temp/Тест/.bzr/checkout/dirstate
C:/Temp/Тест/.bzr/checkout/dirstate
C:/Temp/Тест/.bzr/checkout/dirstate
bzr: ERROR: Could not acquire lock 
"C:/Temp/╨в╨╡╤Б╤В/.bzr/checkout/dirstate": (32, 'CreateFile', 'The 
process cannot access the
file because it is being used by another process.')

4 times(!) locked dirstate and 5th attempt is failed!

I understand that different parts of bzrlib API does not know anything 
about each other, but this locking hell is too much.

Thanks for reading this.

PS: OS locks must die.




More information about the bazaar mailing list