[Exim] Re: Persistent DB connections to MySQL database

Top Pagina
Delete this message
Reply to this message
Auteur: Miquel van Smoorenburg
Datum:  
Aan: exim-users
Onderwerp: [Exim] Re: Persistent DB connections to MySQL database
In article <Pine.LNX.4.43.0205161331080.25333-100000@???>,
Tamas TEVESZ <ice@???> wrote:
>On Thu, 16 May 2002, Richard Gilbert wrote:
> > I was going to use MySQL but I have realised that I don't need the power
> > of MySQL because I still only need to make single key look ups. I was
> > thinking I could instead go back to Exim using NDBM and update that on the
> > fly. What I would like to know is whether it would be safe to update the
> > NDBM database used by Exim directly or whether I would need to lock it.
>
>i would not do that. rebuild it into a different file, then use either
>soft or hardlinks. at least one of these operations are atomic in most
>kernels (to the best of my knowledge; check your os and the archives,
>we had a discussion about that some time ago), so this approach will
>give you an always-consistent state (while things like building the
>new database over the existing one, or removing then copyong, or just
>moving won't neccessarily.)


Soft- or hardlinking is the wrong approach. You cannot link to
an existing file, you need to remove it first before you can create
a new link. That is not atomic.

The correct approach to put a newly generated database file into
place is:

- create it under a temporary name
- mv it into place ("mv" uses rename(2) which is guaranteed atomic).

The is easy to do with a Makefile fragment like this:

somefile.db:    somefile
        exim_dbmbuild somefile somefile.tmp.db
        mv somefile.tmp.db somefile.db


I build all my .db files for exim using a Makefile.

Mike.
--
"Insanity -- a perfectly rational adjustment to an insane world."
- R.D. Lang