Re: [Exim] Updating CDB databases

Top Page
Delete this message
Reply to this message
Author: Richard Welty
Date:  
To: exim-users
Subject: Re: [Exim] Updating CDB databases
On Tue, 10 Feb 2004 13:36:59 +0000 (GMT Standard Time) Richard Gilbert <R.Gilbert@???> wrote:

> > > Our aliases database (and "inverse aliases" database used for address
> > > rewriting) are in CDB files which are updated from a snapshot of a
> > > MySQL database every 15 minutes. I am starting to see problems with
> > > messages being rejected because [entries in] the CDB databases


> Correction                          ^^^^^^^^^^^^


> > > momentarily disappear at the time of the update. cdbmake updates the
> > > database as an atomic operation but this is not sufficient to prevent
> > > problems. I am trying to think of cunning ways to circumvent the
> > > problem, which can cause a few unlucky users to have their messages
> > > rejected, but before doing so I thought I would ask how other people
> > > deal with this problem.
> >
> > Build the CDB elsewhere and use mv or rn to move / rename it to the
> > location you want, either which is atomic.


> I should have said that I have already tried this but I now see problems
> which are of two types: I still see the problem of entries apparently
> disappearing from the database but I also see errors caused by the file
> not being found. The latter are actually an improvement because the
> messages get retried.


> Here are the relevant lines from mu Makefile:


>         cdb_encode.pl aliases | $(CDBMAKE) tmp_aliases.cdb aliases.tmp
>         cdb_encode.pl invaliases | $(CDBMAKE) tmp_invaliases.cdb invaliases.tmp
>         mv invaliases.cdb invaliases.cdb.old
>         mv tmp_invaliases.cdb invaliases.cdb
>         mv aliases.cdb aliases.cdb.old
>         mv tmp_aliases.cdb aliases.cdb


> Moving the files to .old files was intended to allow any process which had
> the file open to continue, but I don't know enough about the low-level
> detail of how file handles mv commands and i-nodes behave.


change some of those mv commands to cp commands and you should
reduce the window for failure considerably, e.g.

        cp invaliases.cdb invaliases.cdb.old
        cp tmp_invaliases.cdb invaliases.cdb
        mv aliases.cdb aliases.cdb.old
        mv tmp_aliases.cdb aliases.cdb


this will be slower and take some free disk space, but the window
where there is no file should diminish into insignificance.

richard
--
Richard Welty                                         rwelty@???
Averill Park Networking                                         518-573-7592
    Java, PHP, PostgreSQL, Unix, Linux, IP Network Engineering, Security