Re: apr_dbm and concurrency

Branko Čibej <[email protected]>
Newsgroups gmane.comp.apache.apr.devel
Organization The Apache Software Foundation
Message-ID <[email protected]>
On 25.09.2023 16:58, Joe Orton wrote:
> It is unspecified whether the apr_dbm.h interface is safe to use for
> multiple processes/threads having r/w access to a single database.
> Results appear to be:
>
> - sdbm, gdbm are safe
> - bdb, ndbm are not safe
>
> (Berkeley DB obviously can be used in a way which is safe for multiple
> r/w users but it appears to require using one of the more complicated
> modes of operation via a DB_ENV, and changing to that would not be
> backwards compatible with the current db format. Corrections welcome,
> not a database expert)

IIRC, Berkeley DB multi-process concurrency is managed through an 
on-disk "register" file external to the actual key/value store. The 
key/value store format is not affected by the presence of this file. The 
DB_REGISTER mechanism was introduced in BDB 4.4 (now long defunct) and 
can be used for both concurrency control and automatic database 
recovery. The client-side code for this can be lifted from Subversion.

(I was involved in designing this mechanism for BDB and implementing its 
use in Subversion, but that was ages ago -- back in 2005. There may be 
better ways do do this in newer versions of Berkeley DB).

TL;DR: all upstream supported versions of BDB should have this mechanism 
available and APR can detect if it's being used without changing the 
API, and even "upgrade" existing databases with the register file on the 
fly without affecting the actual database.

-- Brane
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.