On Mar 8, 2006, at 8:01 AM, Helmut Tschemernjak wrote:


Hello Adam, all,

Cross platform locking is defiantly very important. The goal should be to use the identical sqlite DB via UNIX, AFP, SMB, NFS and others. My opinion is that it is not needed to have any additional open parameters, just use the locking features which are in common between all platforms.

Using an additional TCP/IP server is more complex in term of cross platform compatibility and may be an overkill in terms of performance, and will introduce additional problems.

At present the os_unix.c has some problems, I don't recall all its details so here is just an estimate:

Multiple locks are getting unlocked with one call
- This does not work on AFP and SMB

A Read lock gets turned into a writer lock (and or back?)
- This does not work on AFP, SMB has limited support for it.

The current lock offset will not allow to copy open DB files if the database gets larger than 0x40000000 bytes. This is because locked regions cannot be copied under Windows, we changed it to:

#define PENDING_BYTE      I64CONST(0x7fffffffffff0000)
#define RESERVED_BYTE     I64CONST(0x7fffffffffff0001)
#define SHARED_FIRST      I64CONST(0x7fffffffffff0002)

Advisory versus mandatory record locking
AFP and SMB is doing mandatory locking which means other clients cannot read locked file areas, advisory locking means that we can ready any data therefore we must call lock first before reading bytes.

The benefit of supporting the OS based locking is that after a program exits it will automatically cleanup all locks. Windows has some "oplock" features which will handle remote locks completely on the Windows SMB clients as long as only one writer uses the file.

It should not be this difficult to use only locking features which are in common cross major platforms and network file systems.


That's basically the goal, but instead of simply making '.lock' files the only locking mechanism (the only type of locks that work for some variants of NFS - thus the only locking features which are in common across major platforms and network file systems), we want to allow the developer to make the decision about the 'lowest common denominator' locking for the environment their database will be used in.

- adam


Reply via email to