Guardian Digital Inc. > InfoCenter > Mailing List Archives > Amavis

Amavis Mailing List Archive

From: Bart Boelaert (bboelaert@xtradev.com)
Date: Mon Dec 27 2004 - 17:27:24 EST

Hi all,

I'm currently configuring a mail server with the following set-up :

Distribution : Fedora core 2
Kernel version : 2.6.9-1.6
Mail server : postfix-2.1.5
MySQL server : MySQL-server-4.1.8-0
Perl DBI : perl-DBD-MySQL-2.9004
Amavis : amavisd-new-2.2.0

General scheme :
 smtpd (Postfix)-> pre-cleanup (Postfix) -> qmgr (Postfix) -> smtp-amavis
(Postfix) -> Amavisd-new (AV + SpamAssassin) -> local smtpd (Postfix) ->
cleanup (Postfix) -> (normal mail processing)

Both Postfix and Amavisd-new do lookups in SQL tables of redundant MySQL
servers (1 on the mail server itself and 1 on a dedicated dbase server). The
whole process has been tested several times in several ways and works
flawlessly, except in one specific condition :

After a certain period of inactivity (= no mails to be processed), I get the
following error messages in the log file :

Dec 27 22:48:38 mailhost amavis[15408]: (15408-05) lookup_sql: 2006, MySQL
server has gone away
Dec 27 22:48:38 mailhost amavis[15408]: (15408-05) NOTICE: Disconnected from
SQL server
Dec 27 22:48:38 mailhost amavis[15408]: (15408-05) TROUBLE in check_mail:
cached FAILED: DBD::mysql::st execute failed: MySQL server has gone away at
(eval 36) line 257, <GEN2> line 164.
Dec 27 22:48:38 mailhost amavis[15408]: (15408-05) PRESERVING EVIDENCE in
Dec 27 22:48:38 mailhost postfix/smtp[18000]: 1FCB27E3A:
to=<bart@bartboelaert.com>, relay=[], delay=1206,
status=deferred (host[] said: 451 4.5.0 Error in
processing, id=15408-05, cached FAILED: DBD::mysql::st execute failed: MySQL
server has gone away at (eval 36) line 257, <GEN2> line 164. (in reply to
end of DATA command))

It seems that amavisd-new can not recover from this error (submitting a
second message gives the same error in the log files).
When this error occurs I can successfully connect to the MySQL server via
the mysql client. The DSN specified in the amavisd.conf file is as follows :
@lookup_sql_dsn =
   ( ['DBI:mysql:database=mydb;host=localhost;port=3306', 'dbuser',
     ['DBI:mysql:database=mydb;host=;port=3306', 'dbuser',
'dbpwd'] );
I suppose that according to the above DSNs, the local MySQL connection is
made via a UNIX socket.

Some debugging revealed that in the lookup_sql routine amavisd-new thinks it
is still connected to the MySQL server (sql_connected = 1), executes the
query and goes in error. Before dying, it sets the sql_connected flag to 0
and does a disconnect of $self->{dbh}.
After submitting a second message, the lookup_sql routine correctly calls
the connect_to_sql routine and gets back a valid $dbh (so, apparently,
establishing the connection does succeed). But after executing the SELECT
query the "MySQL server has gone away" reappears.
I already tried adding Autocommit => 1 to the connection parameters and
setting $dbh->{mysql_auto_reconnect} = 1 if there is a $dbh in the
connect_to_sql routine, but still no luck. My first conclusion was that it
had something to do with a time-out of the MySQL connection.

Could somebody help me out please? This system has to go life within a few
days!!! If the MySQL part of amavisd-new is not working as it should, I will
have to disable this - otherwise very nice - feature! The last thing I want
is e-mail that doesn't come through!!!
Debugging Perl code is really nothing for me (I'm not a programmer, just a
network admin that wants systems to do what they are supposed to do and
customers that are very happy with the solutions I've implemented)!

Thanks in advance!


SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
AMaViS-user mailing list

[ About Guardian Digital ] - [ Press Center ] - [ Contact Us ] - [ System Activation ] - [ Reseller Info ] - [ Online Store ] - [ Site Map ]
Copyright (c) 2000 - 2004 Guardian Digital, Inc. Linux Lockbox and EnGarde are Trademarks of Guardian Digital, Inc.