Re: [Exim] race condition, locking, crash

Góra strony
Delete this message
Reply to this message
Autor: Philip Hazel
Data:  
Dla: Peter D. Gray
CC: exim-users
Temat: Re: [Exim] race condition, locking, crash
On Sat, 22 Nov 2003, Peter D. Gray wrote:

> It occurs to me that there may be a race condition
> when updating DB style maps which could cause
> exim to crash. If you are using any style of
> DB database which uses both a .pag and a .dir file
> then the exim_dbmbuild will rename one of the
> files, then the other. If exim is
> accessing the database between the move of the
> .pag file and the .dir file then I believe there
> is a good chance of a crash. At best, the result of
> any lookups would be undefined.
>
> Am I right in this?


Possibly, but I don't know enough about how the dir/pag libraries work
to know if it actually matters or not.

Strictly, the only time of danger is when the DBM library has opened one
of the files and not the other. Once both files are open, Exim will
continue to use those versions of the files, even if the names are
change to point to new versions.

> If so, the fix would seem to be some form of locking
> on the DB files so exim would pause while exim-dbmbuild
> tampered with the files.


I do not want to build in general locking for DB file reading (e.g.
alias lookups), because for the one-file libraries it is not needed and
would therefore just add overhead.

Perhaps one way to solve this is to arrange for both files to be in a
special directory, and then to rename the directory to bring a new set
into service.

However, I cannot recall any reports of people actually having problems
in practice. But then, maybe not many use those DBM libraries.

--
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.
Get the Exim 4 book:    http://www.uit.co.uk/exim-book