Sunday, September 17, 2006

NFS Locking

It doesn't work. Atleast not for me. Maybe it does in a properly configured environment. But this certainly isn't one.

Software that lock files can suffer badly when the files they lock are on NFS. And with most home directories being NFS mounted, this means that sooner or later you're going to encounter such software.

My first practical experience with NFS locking issues was during a ill-fated talk on Arch/TLA to a (thankfully) small group of friends. Arch/TLA doesn't work on NFS. All our demo machines had NFS-mounted directories. End of talk. Well, not exactly, since we did manage to salvage some part of it.

Then, of course, came the SQLite database problem. Or was it the PHP PECL compilation problem? Whatever. And lately, I discovered that Skype,stores its configuration files and uses locks to manage it's databases. On NFS, it just refuses to start, or takes ages to begin. I've experimented with moving the files to /tmp and creating a soft-link, which does work --- Skype starts up. But an unrelated(?) problem causes it to crash when I try to connect. Using Google to find out more leads to pages which complain of ABI differences between Skype's binary and the system glibc, and given that Skype is closed-source, can't do much about it. As an aside, I'm not using Skype, was just trying to debug the problem. For VoIP, I recommend GTalk or its free implementation at http://tapioca-voip.sourceforge.net. Note that I do not use VoIP.

So how do you assure conflict-free access to your files across all local disks as well as NFS? There should be a general solution, but my guess is, it varies from application to application. For a good example of how a lock-free mail spool was implemented, see the Maildir format invented by DJB.

No comments: