OpenOffice.org recently made it's way into the Debian AMD64 distribution which from my point of view is a fantastic bit of news. I immediatly installed it and fired it up only to have it fall over in a big heap. It wasn't quite ready for the prime time. A week or so went by and another version appeared in testing. I tried again installed it and fired it up. To my joy it seemed stable. Sadly my joy was short lived. No sooner than I had aquired a working OpenOffice than I had a broken OpenOffice. Everytime I opened a document over an NFS share it was read only. When I tried to close said document OpenOffice would hang. I moved a document to a local partition and found that I could open it and work on it. About 50% of the time when I came to close OpenOffice it would hang.

The OpenOffice maintainers seem to think that the problem is with the servers NFS configuration and the way it handles file locking. As such they have come up with many and varied different ways that one can configure file locking to make OpenOffice work - so far I haven't found one that works.

Having been a programmer for many years now I have come to learn a thing or two about software. One of the things that I have learnt is that if every other piece of software on a system can open, read and write files across NFS and yours can't it's probably your problem not the systems. Having said that I have some sympathy with the Open Office team as file locking in NFS is terrible but that is the price you pay for having a networked file system. This problem is currently affecting a lot of people and I struggle to believe they they have all systematically configured NFS incorrectly (unless there is a really big gotcha in the NFS configuration). I'm hoping that the OpenOffice.org developers take a slightly more pragmatic approach to this problem soon and find a fix that doesn't involve reconfiguring the worlds NFS servers.

In the mean time here is a work around that seems to work. The only downside of this work around is that it turns off file locking altogether so two people could open a file for writing. If you have a small network and most documents are in a users home directory this probably won't be much of an issue.

Solution One: Turning Off File Locking

Open the file /usr/lib/openoffice/program/soffice (generally /opt/openoffice2/program/soffice on non-debian based machines) and comment out the following lines:

# file locking now enabled by default
SAL_ENABLE_FILE_LOCKING=1
export SAL_ENABLE_FILE_LOCKING

To produce: 

# file locking now enabled by default
#SAL_ENABLE_FILE_LOCKING=1
#export SAL_ENABLE_FILE_LOCKING

For some reason setting SAL_ENABLE_FILE_LOCKING=0 is not good enough to make this solution work although I would love to know why. A better solution is to make sure tht file locking it working which I'm currently investigating.

Solution Two: Correcting NFS File Locking

This is currently work in progress. I've discovered another application (digikam) that requires NFS file locking so I am going to fix this. Update: Deep joy and celebration I have found a real solution to the locking problem. Forget NFSv3 altogether and just upgrade to NFSv4. The upgrade process if you are running a recent kernel (2.6 or above) is fairly painless requiring you to learn a new syntax for /etc/exports and probably make a few bind mounts. I've written a guide to installing NFSv4 if you want to try this out yourself.