Apple added special hacks to their release of SQLite 3.1.3 that
allow it to work on remote filesystems with broken file locking.
For various reasons, those hacks have not been incorporated into
the SQLite core, yet.

A bit more detail; Apple shipped with 3.1.3 with locking support for various filesystems. The implementation attempts to be defensive when locking on non-local filesystems. In particular, it makes the assumption that NFS servers will sometimes completely lie about their locking capabilities. Thus, it falls back to .lock files and treats every lock request as an exclusive lock. Efficient? Nope. Safe? Yup -- well -- as safe as any DB operation on a network can be.

Version 3.1.5 and beyond of SQLite contained changes to the great fsync() vs. FULL_FSYNC conundrum such that integrating 3.1.5 and beyond into Apple's source was not entirely trivial. That is in the works and we will post the changes back to DRH as soon as possible. Apple has no interest in forking SQLite or maintaining some weird derivative (the source is already available, anyway).

You can take a look at what Apple has done for OS X here:

http://www.opensource.apple.com/darwinsource/10.4/SQLite-28/

Don't be mislead by the project name--it is SQLite 3. I haven't studied it closely, but it should allow you to build exactly what Apple shipped. The Makefile has references to locking callbacks, so this might be relevant:

Yeah -- the project name reflects an internal serial number. It confuses us, too. Sorry.

Right now based on my limited testing I have some concerns over the performance of the locking. The implementation may well not be as optimal as it can be or possibly it is optimal but my code isn't optimised for network access. I don't know yet.

That is not surprising. With NFS, the only safe assumption is that locking is utterly broken. If your application will be run in an environment where you can guarantee that locking works on NFS -- that the NFS server is not broken -- then change the "what type of locking system to use" code to return the same locking mechanism as the local filesystem.

b.bum

Reply via email to