Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 262819 - mail-mta/exim enhancement (cleanup of serialization files during startup)
Summary: mail-mta/exim enhancement (cleanup of serialization files during startup)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Fabian Groffen
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-17 17:56 UTC by Jaco Kroon
Modified: 2015-05-05 12:56 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jaco Kroon 2009-03-17 17:56:46 UTC
Hi,

According to chapter 19 one should manually ensure that serialize-* files are nuked during system bootup if using the serialize_hosts option (which is a good thing on bandwidth constricted connections).  Adding the following three lines to the top of the start() function in the start script achieves this, and I can't see it doing any actual harm.

    ebegin "Removing old serialization files (exim)"
    /usr/bin/find /var/spool/exim/db -name "serialize-*" -exec rm {} \;
    eend $?

There are other ways of doing this too.  Either way, I see this as an enhancement, not a serious problem.  It's IMHO probably a good thing to rather clean up these files during exim startup rather than in local.start (as exim would actually already be operating at that time).

Reproducible: Always

Steps to Reproduce:
Comment 1 Colin Morey (RETIRED) gentoo-dev 2009-03-17 22:06:26 UTC
This needs a little more work, ideally it should query the exim binary and config options to determine if seralize_hosts is in use, if so, it should then purge the spool directory (which may or may not be /var/spool/exim/db), I'll have a think on this a bit and see if/when it will make it into the tree.
Comment 2 Torsten Veller (RETIRED) gentoo-dev 2009-06-24 13:33:18 UTC
Reassign to net-mail herd as peitolm retires
Comment 3 Fabian Groffen gentoo-dev 2009-07-03 08:01:42 UTC
Drawback of cleaning them upon exim start is that you can't easily restart exim without cleaning the files (if you don't want that).  It should only be done at (re)boot.  It almost feels like those files should be placed in /tmp instead, such that they are cleaned if the system was configured as such.
Comment 4 Jaco Kroon 2011-08-25 14:30:58 UTC
Fabian,

Why not?  When restarting exim the delivery instances will be stopped too as far as I understand, so there should not be any problems with nuking those files.  I've had cases where exim died, leaving behind these serialization files resulting in a system that was unable to delivery outbound email to a couple of servers.

Can anybody please indicate exactly what I'd need to get done on this additionally to get it merged?
Comment 5 Fabian Groffen gentoo-dev 2011-08-25 14:51:45 UTC
why would putting the serialisation files in /tmp not work for you?
Comment 6 Jaco Kroon 2015-05-04 11:58:29 UTC
Hi Guys,

Would just like to bump this.  Just for clarity, the manual states:

"Because Exim operates in a distributed manner, if several messages for the same host arrive at around the same time, more than one simultaneous connection to the remote host can occur. This is not usually a problem except when there is a slow link between the hosts. In that situation it may be helpful to restrict Exim to one connection at a time. This can be done by setting serialize_hosts to match the relevant hosts.

"Exim implements serialization by means of a hints database in which a record is written whenever a process connects to one of the restricted hosts. The record is deleted when the connection is completed. Obviously there is scope for records to get left lying around if there is a system or program crash. To guard against this, Exim ignores any records that are more than six hours old.

"If you set up this kind of serialization, you should also arrange to delete the relevant hints database whenever your system reboots. The names of the files start with misc and they are kept in the spool/db directory. There may be one or two files, depending on the type of DBM in use. The same files are used for ETRN serialization."

The second paragraph in particular applies.  Both a program (exim) or system crash can trigger this.  The 6 hour delay is a workable solution but it does cause needless delays.  We still see this quite often, most of the time it's caused by system crashes (usually power cuts).

http://www.exim.org/exim-html-current/doc/html/spec_html/ch-exim_utilities.html#SECThindatmai

Is hinting at the fact that exim_tinydb can also be used to clean up that file.

Please note that previous information applied to exim 3 and not exim 4, thus the find mechanism is outdated.  My suggestion would be to simply add this as pre-start:

exim_tinydb /var/spool/exim/ misc

The whole process doesn't even take a second, so honestly there really isn't much reason to not do this.
Comment 7 Fabian Groffen gentoo-dev 2015-05-05 11:12:15 UTC
Just to be clear here:

you suggest we add a call to exim_tidydb in the init-script for start/restart for all databases

Is this right?  I think this makes sense judging from the documentation.  It's up to the sys/mailadmin to run the tool when exim runs, but removing stale entries when Exim is (re)started will not impact anything, so a safe and sensical option.
Comment 8 Jaco Kroon 2015-05-05 12:02:48 UTC
I was actually only considering misc to clean up the serialization stuff, but as you state there is no harm in cleaning all.  So yes - for all databases would be good.

Based on my systems (and someone will have to verify that this is indeed generic/good enough) I've got a bunch of .lockfile files for the databases, and since I also store a number of .dbm files in there for autoresponder rate limiting my suggested solution would then be:

clean_dbs() {
   local dbf
   for dbf in /var/spool/exim/db/*.lockfile; do
       /usr/sbin/exim_tidydb /var/spool/exim "$(basename "${dbf}" .lockfile)"
   done
}

And then arrange for clean_dbs to be called prior to actually starting exim.

This does output to the terminal, eg:

Tidying Exim hints database /var/spool/exim/db/callout
deleted ... (too old)
...
Tidying complete
Tidying Exim hints database /var/spool/exim/db/misc
Tidying complete
Tidying Exim hints database /var/spool/exim/db/retry
Tidying complete
Tidying Exim hints database /var/spool/exim/db/wait-remote_smtp
updated somename:17
Tidying complete

This may not be acceptable, so if not, just do for example:

einfo "Cleaning DBs"
clean_dbs &>/dev/null
eend $?

I normally like knowing what's going on, but again, I'd only really like to know if cleanups was made and the output is completely useless for the most part.
Comment 9 Fabian Groffen gentoo-dev 2015-05-05 12:16:35 UTC
right, this was the approach I was taking here :)
Comment 10 Fabian Groffen gentoo-dev 2015-05-05 12:56:28 UTC
I've committed this to 4.85, please let me know if this does what you need.  Thanks!