correct • elegant • free

△ comp.lang.perl △

◅ Is perl tail recursive?

GDBM_File barfs on NFS mounted disk ▻

GDBM_File barfs on NFS mounted disk

In article <4aq2pu$>, Chris Abajian
<> wrote:
>Without spending a day reading the sources, what does GDBM do that
>NDBM does not?  Why is this, and is there a fix for it?

In a word, locking.

NDBM takes no steps to prevent readers and writers of the database
accessing it simultaneously.  It's therefore risky to use NDBM in
situations where you care about your data (unless you implement
your own locking).  I've not seen an NDBM database become permanently
corrupted, but I have seen dbm_nextkey() (corresponds to Perl's
`each') go into a loop, which is bad enough.

On Solaris 2 systems, GDBM uses fcntl(2) locking to ensure that
there is only ever one writer xor multiple readers of the database.
(On systems lacking fcntl(2), it will use flock(2) instead, but
that's not relevant to this problem.)

Locking files mounted with NFS is fraught, to say the least.  In
theory, fcntl(2) locks work over NFS.  Provided both NFS server
and client are running Sun operating systems (either SunOS 4, or
Solaris 2), suitably patched, the theory seems to work in practice.

Once you start introducing other types of system, the theory breaks
down.  FreeBSD NFS clients, for instance, don't attempt to use
lockd, so each client is blissfully unaware of locks held by other
clients.  We had a dedicated NFS server on trial which worked fine
provided the clients were Solaris 2 or SunOS 4.1.4, but SunOS
4.1.3_U1 clients hung in much the manner you describe.

Your options would seem to be:

i) report the bug to Sun and DEC---it's even possible they have a
patch that fixes it already;

ii) use NDBM (or the superior Berkeley DB, which also does no
locking) and hope that your data doesn't get trashed;

iii) use NDBM or DB and implement your own locks with files.

Tim Goodwin   | "After all, what did Brunel, Watt, Boulton and
Unipalm PIPEX | Telford do that was complex?  I could have built
Cambridge, UK | the Great Western Railway on my own." -- Ian Batten

Original headers:

From: (Tim Goodwin)
Newsgroups: gnu.misc.discuss
Subject: Re: GDBM_File barfs on NFS mounted disk
Date: 15 Dec 1995 17:55:02 GMT
Organization: Unipalm PIPEX
Message-ID: <4ascpm$>
References: <4aq2pu$>

△ comp.lang.perl △

◅ Is perl tail recursive?

GDBM_File barfs on NFS mounted disk ▻