[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: Race condition in handling hash type lookup table Victor Duchovni Wed Apr 01 04:00:28 2009

On Sat, Mar 28, 2009 at 03:33:30PM +0100, Adam Osuchowski wrote:

> Hello.
> There is a race condition in handling hash type lookup table. Problem results
> from that smtpd (and probably other daemons) keeps database files open for all
> time it is running. During that, if database file will be changed (e.g.
> postmap will be invoked to rebuild database file), smtpd will not find
> existing keys because binary arrangement of database file will be different.
> Problem appears when number of entries in database is greater than some value
> (on my systems it was 4174, but I don't know what it results from, so it may
> be different on other systems). Furthermore, I don't know if it is bug in
> Postfix or Berkeley DB code because I can't find if it is allowed to change
> database files if other process keeps it open.

Berkeley DB will attempt to mmap sufficiently small read-only databases,
but if the database grows the mapping may not cover the entire file. The
best solution is to use CDB for r/o tables, but with Berkeley DB you
can use "mv" to update tables atomically.