[OpenAFS] sqlite on AFS will not work, even with whole-file locking

Hans-Werner Paulsen hans@MPA-Garching.MPG.DE
Wed, 21 Apr 2010 13:28:20 +0200


On Mon, Apr 12, 2010 at 12:34:23AM -0400, Derrick Brashear wrote:
> On Sun, Apr 11, 2010 at 11:13 PM, Adam Megacz <adam@megacz.com> wrote:
> >
> > Brandon Simmons <brandon.m.simmons@gmail.com> writes:
> >> Thanks for the response. It seems like whole-file locking in sqlite
> >> would be a good choice for me in any case,
> >
> >> In a situation where the whole-file locking scheme is used, would AF=
S
> >> be an acceptable choice? Would it be better than NFS?
> >
> > I had the same idea, and tried it. =A0It does not work. =A0Your datab=
ases
> > will get corrupted. =A0I never figured out why, although I did confir=
m
> > that sqlite was in fact requesting only whole-file locks.
> >
> > It would be nice if it worked, though. =A0There are a lot of applicat=
ions
> > out there where writes to the database are extremely rare, so
> > invalidating all the clients' caches is not a problem.
>=20
> do you happen to know what the corruption looked like (blocks of
> zeroes, just not readable, something else)
>=20
> --=20
> Derrick

On 27 Oct 2008 I had a question about flock on AFS, because I did not
understand how flock should work on AFS at all. May I repeat this questio=
n:

Hello,
today I am totally confused how the flock(2) call should work on
AFS files.
Normally locking works in the following way:
1        fd =3D open("afs-file",O_RDWR)
         do something
2        flock(fd,LOCK_EX)
         do something with "afs-file"
3        flock(fd,LOCK_UN)
         do something
4        close(fd)

When there are two processes (on different machines) executing that
code, the (2) flock call has to update the local copy of the afs-file,
otherwise locking is useless. And the (3) flock call has to sync the
local copy with the fileserver.
Writing a small test program I see that this synchronization isn't done.
How can I use the flock(2) call on AFS files?
Thank you for any help,

--=20
Hans-Werner Paulsen		hans@MPA-Garching.MPG.DE
MPI f=FCr Astrophysik		Tel 089-30000-2602
Karl-Schwarzschild-Str. 1	Fax 089-30000-2235=09
D-85741 Garching