[Python-Dev] test_fcntl on Solaris 8

Thomas Wouters thomas@xs4all.net
Sun, 15 Apr 2001 18:03:08 +0200


On Sat, Apr 14, 2001 at 09:17:27PM -0500, Guido van Rossum wrote:

> While testing Python 2.1 on SF's Solaris 8 box, I noticed that it
> hangs forever in test_fcntl, on this line:

>   rv = fcntl.fcntl(f.fileno(), FCNTL.F_SETLKW, lockdata)

> Why could this be?  Could it be that the NFS lock server is stuck?

It could very well be that. NFS (version 2 or 3) locking is really, really
dumb. Not just the act of locking over NFS, but the whole protocol for
locking over NFS. If you consider that NFS is meant to be stateless, you can
quickly realize how locking (as well as the concept of 'open files' and what
should happen when you delete open files) do not fit well with NFS. There
are some other braindeadisms with NFS locking, though: it's not possible to
break a lock. If a machine is locking a file, and the machine goes down, the
lock stays in effect until the machine is back up. And 'a machine' is
identified with an ipaddress, so if it gets a new IP, tough. If it stays
down indefinately, tough.

And then there's the implementation side. I have yet to find an NFS server
or client that deals sanely with locks either way. Either they're too
lenient (not very often) or too strict, or they just don't talk well with
the other side. If you want to do locking over NFS, don't use lockf or
flock, use the link/stat lock method (see Mailman's LockFile module for a
somewhat expanded implementation of sane locking over NFS.)

On the plus side, there's a lot of work being done on NFSv4, which should
fix almost every design error made in NFSv2/3. Including the locking ;)

In any case, the problem on the SF Solaris box could be one of two things: a
hanging lock, in which case renaming/removing the testfile should fix it, or
a communication problem between the Solaris box and the NFS server. The
latter is pretty likely the case if the NFS server is Linux, which is pretty
likely with Sourceforge. You can doublecheck by using a testfile on another
filesystem, which isn't NFS-mounted (like /tmp.)

-- 
Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!