using cdb for 'update' without race condition?

Norman Ramsey <[email protected]> Wed, 09 Apr 2008 22:20:36 -0400
Newsgroups gmane.comp.djb.cdb
Message-ID <[email protected]>
I'm interested in checking out cdb for a database that will be updated
programmatically.  Since the database is 'constant', 'update' is a bit
of a contradiction in terms, but I believe the effect of an atomic
update for a cdb database works like this:

  1. My app reads a database and extracts all the key-value pairs.

  2. My app produces a new set of key-value pairs.

  3. I atomically make a new database. I cannot do this through a C
     API but only via the cdbmake program.  Atomicity is guaranteed by
     the way cdbmake uses the filesystem.

It appears to me that if I want to avoid losing an update via race
conditions that my cdb file needs to be protected by some kind of
lock, and it's up to my app to use liblockfile or something similar.

Can anyone comment on the proposal and analysis above?
I'm particularly eager to know if I've made mistakes.

I suspect this is an FAQ, but I cannot find a Web archive for this
list, nor can I get the ezmlm index command to work (mail sent to
cdb-index was rejected with a polite error message).


Norman