[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Merge tracking: will SQLite make NFS sad?

From: Daniel Rall <dlr_at_collab.net>
Date: 2007-03-05 23:07:40 CET

On Mon, 05 Mar 2007, Florian Weimer wrote:

> * Malcolm Rowe:
> > Well, it's not quite the same. FSFS only requires that whole-file
> > advisory locking works, while SQLite seems to require 'proper' byte
> > range locking.
> They are not essential, byte range locks are only used to increase
> fairness AFAICT.

I just spent some time looking through the latest CVS source code of
SQLite <http://www.sqlite.org/cvstrac/dir?d=sqlite>. To my unfamiliar
eye, things look pretty good even for network file systems.

It appears that POSIX fcntl() byte range locking isn't currently used
to protect actual ranges of data. Instead, when available it's used
to manage lock types to improve concurrency characteristics.

At least on *nix, SQLite uses runtime detection of file system type,
and (possibly) even actual fcntl() behavior, to determine the type of
locking to use (e.g. POSIX fcntl() locking vs. dot locking). See the
sqlite3DetectLockingStyle() and sqlite3TestLockingStyle() routines of

AFAICT, this protects us against file systems which don't fully
support POSIX locking, so long as their APIs they don't lie about
their capabilities.

While this isn't particularly friendly for our general use case,
SQLite even lets you set a fixed locking style at compile-time by
defining SQLITE_FIXED_LOCKING_STYLE to a value from its
sqlite3LockingStyle enumeration:

** The locking styles are associated with the different file locking
** capabilities supported by different file systems.
** POSIX locking style fully supports shared and exclusive byte-range locks
** ADP locking only supports exclusive byte-range locks
** FLOCK only supports a single file-global exclusive lock
** DOTLOCK isn't a true locking style, it refers to the use of a special
** file named the same as the database file with a '.lock' extension, this
** can be used on file systems that do not offer any reliable file locking
** NO locking means that no locking will be attempted, this is only used for
** read-only file systems currently
** UNSUPPORTED means that no locking will be attempted, this is only used for
** file systems that are known to be unsupported
typedef enum {
        posixLockingStyle = 0, /* standard posix-advisory locks */
        afpLockingStyle, /* use afp locks */
        flockLockingStyle, /* use flock() */
        dotlockLockingStyle, /* use <file>.lock files */
        noLockingStyle, /* useful for read-only file system */
        unsupportedLockingStyle /* indicates unsupported file system */
} sqlite3LockingStyle;

  • application/pgp-signature attachment: stored
Received on Mon Mar 5 23:12:08 2007

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.