ugh.book

(singke) #1

296 NFS


We found the segment of code that was causing the problem. When
Emacs tries to open a file to edit, it tries to do an exclusive create on
the superlock file. If the exclusive create fails, it tries 19 more times
with a one second delay between each try. After 20 tries it just
ignores the lock file being there and opens the file the user wanted. If
it succeeds in creating the lock file, it opens the user’s file and then
immediately removes the lock file.

The problem we had was that /usr/lib/emacs/lock was mounted over
NFS, and apparently NFS doesn’t handle exclusive create as well as
one would hope. The command would create the file, but return an
error saying it didn’t. Since Emacs thinks it wasn't able to create the
lock file, it never removes it. But since it did create the file, all future
attempts to open files encounter this lock file and force Emacs to go
through a 20-second loop before proceeding. That was what was
causing the delay.

The hack we used to cure this problem was to make
/usr/lib/emacs/lock be a symbolic link to /tmp, so that it would
always point to a local directory and avoid the NFS exclusive create
bug. I know this is far from perfect, but so far it is working correctly.

Thanks to everyone who responded to my plea for help. It’s nice to
know that there are so many friendly people on the net.

The freezing is exacerbated by any program that needs to obtain the name
of the current directory.

Unix still provides no simple mechanism for a process to discover its “cur-
rent directory.” If you have a current directory, “.”, the only way to find out
its name is to open the contained directory “. .”—which is really the parent
directory—and then to search for a directory in that directory that has the
same inode number as the current directory, “.”. That’s the name of your
directory. (Notice that this process fails with directories that are the target
of symbolic links.)

Fortunately, this process is all automated for you by a function called
getcwd(). Unfortunately, programs that use getcwd() unexpectedly freeze.
Carl R. Manning at the MIT AI Lab got bitten by this bug in late 1990.
Free download pdf