[Date Prev][Date Next] [Chronological] [Thread] [Top]

RE: back-bdb DB_RECOVER and soft restart

> -----Original Message-----
> From: Hallvard B Furuseth [mailto:h.b.furuseth@usit.uio.no]
> Sent: Saturday, September 13, 2003 7:59 AM
> To: mhardin@symas.com
> Cc: openldap-devel@OpenLDAP.org; Howard Chu
> Subject: RE: back-bdb DB_RECOVER and soft restart
> Matthew Hardin writes:
> > On startup each instance of back-bdb will do the following:
> > (...)
> > 2. Attempt to place a write lock on the lock file. (...)
> > (...)
> > 5. Wait for a read lock on the lock file and leave it there for the
> >    life of the back-bdb instance.
> Why get a read lock when you already have a write lock?

Because only one process can have a write lock on a file, while many can
have a read lock. Also, a write lock cannot be obtained if any other process
has a read lock. If all processes using the BDB environment place read locks
on the lock file while they are using the environment, on exit a process can
tell if it's the last process using the BDB environment because it will be
able to obtain a write lock. It then truncates the lock file to zero length
to mark a clean shutdown and exits.

Demoting a write lock to a read lock at that point signals that the recovery
has completed and that other processes can use the BDB environment.

> Besides, if you will use libraries/liblutil/lockf.c:lutil_lockf, that
> may use lockf() which only supports 'locks', not 'read/write locks'.

Thanks for the tip. I'll have to look into that.

> --
> Hallvard

Matthew Hardin
Symas Corporation
Packaged, certified, and supported LDAP software: