[Rd] Read/write file locking mechanism using SQL?

Henrik Bengtsson hb at stat.berkeley.edu
Wed Apr 30 17:10:23 CEST 2008


Hi,

I've got data stored in multiple files on a shared file system.  I
wish to have multiple processes/hosts read and write to these files
simultaneously.  When a process wish to write to a file no other
processes may write to nor read from the file.  If no process is
writing to the file, any number of processes may read from it.  ...and
the solution should be very simple and work automagically in the
background (no/minimal setup required by the user).

The above can be achieved via file locking mechanism where writers
need to require a write lock before writing, and readers need to
require a read lock before reading.  Any number of read locks can be
handed out, but only if no write lock is already in place.  Write
locks can only be obtained if no other locks (read or write) are
handed out.  The locking mechanism is per file.

I am locking for a cross platform solution in R that works on any file
system, i.e. I am not in control of the operating systems of the hosts
nor the file system where the data files are stored.  I've been
suggested to use, for instance, RSQLite database since it provides
atomic transactions (and is available on Windows, *nix & OSX).  I can
image to have a table where each entry is indexed by a file and it
keeps track of how many read and write locks are active.

Does anyone know of existing solution for this, or has ideas how this
could be implemented?  I appreciate any references/comments.

/Henrik



More information about the R-devel mailing list