[exim] Is this flaky Exim behaviour due to MySQL?

Top Pagina
Delete this message
Reply to this message
Auteur: Ernie Dunbar
Datum:  
Aan: exim-users
Onderwerp: [exim] Is this flaky Exim behaviour due to MySQL?
Server vital statistics:
Debian Lenny
Exim 4.69
MySQL

We just made our new Exim server live yesterday, and one of the first
things I noticed that hadn't come up in testing was error messages in the
paniclog like this:

2010-01-15 14:23:42 1NVuZS-0002Ly-EE == SOMEUSER@???
R=mysql_user_lightspeed T=local_mysql_delivery_lightspeed defer (-25):
failed to expand headers_add or headers_remove while writing to
tmp/1263594222.H193227P9505.pop.lightspeed.ca: integer expected but
"ERROR" found

The odd thing is that these messages appear to get delivered instead of
deferred, but we've had some issues today with our queue getting backed
up, and I've started looking into this deeper. I'm starting to suspect
that the Mysql server flakes out on us under load, since we never had any
errors like this during testing. Exim does some MySQL queries in the
transport section (and many other places) which seem to result in the
"ERROR" found.

The transport local_mysql_delivery_lightspeed looks like this:

local_mysql_delivery_lightspeed:
  driver        = appendfile
#  file         = /var/mail/$local_part
#  directory    = /home/$local_part/.maildir
  directory     = /home/${local_part}/Maildir/
  maildir_format
  delivery_date_add
  envelope_to_add
  return_path_add
  user          = mail
  group         = mail
  mode          = 0660
  # at this time, we know a local user to get his individual preferences
to tag the mail
  # the '${eval:$header_X-Spam-Score-Int:}' is is a hack to cope with
negative ints that seem to be parsed as strings, thus failing the
comparsion
  # if there's no X-Spam-Score-Int header set by data-acl above, don't
panic ;-)
  # another hack is that we remove important headers, we add later to be
sure there are no multiple versions from earlier relays, or forged ones
(this is BUGGY right now as it merges all equal headers!)
  #     therefore i implemented the
${sg{$header_X-Spam-Score-Int:}{^.*\n}{}} regex hack, that strips all
  headers_remove = Subject : X-Spam-Flag : X-Spam-Score-Int : X-Spam-Score
: X-Spam-Bar : X-Spam-Report
  headers_add   = "X-Spam-Threshold: ${lookup mysql{ \
                                        SELECT spam_threshold \
                                        FROM mailbox \
                                        WHERE
username='${quote_mysql:$local_part@$domain}'
\
                                        AND domain='${quote_mysql:$domain}' \
                                      }{$value}{ERROR}}\n\
                  X-Spam-Score: $header_X-Spam-Score:\n\
                  X-Spam-Score-Int: $header_X-Spam-Score-Int:\n\
                  X-Spam-Bar: $header_X-Spam-Bar:\n\
                  X-Spam-Report: $header_X-Spam-Report:\n\
                  X-Spam-Flag: ${if def:header_X-Spam-Score-Int:{\
                                        ${if

>={${eval:${sg{$header_X-Spam-Score-Int:}{^.*\n}{}}}}\

                                                {${lookup mysql{ \
                                                        SELECT
spam_threshold*10
\
                                                        FROM mailbox \
                                                        WHERE
username='${quote_mysql:$local_part@$domain}'
\
                                                        AND
domain='${quote_mysql:$domain}'
\
                                                }{$value}{ERROR}}}{YES}{NO}}\
                                        }{\
                                        UNKNOWN\
                                }}\n\
                  Subject: ${if def:header_X-Spam-Score-Int:{\
                                        ${if

>={${eval:${sg{$header_X-Spam-Score-Int:}{^.*\n}{}}}}\

                                                {${lookup mysql{ \
                                                        SELECT
spam_threshold*10
\
                                                        FROM mailbox \
                                                        WHERE
username='${quote_mysql:$local_part@$domain}'
\
                                                        AND
domain='${quote_mysql:$domain}'
\
                                                }{$value}{ERROR}}}{${lookup
mysql{ \
                                                                        SELECT
spam_threshold
\
                                                                        FROM
mailbox
\
                                                                        WHERE
username='${quote_mysql:$local_part@$domain}'
\
                                                                        AND
domain='${quote_mysql:$domain}'
\
                                                                   }{$value}{ERROR}}$h_subject:}{$h_subject:}}\
                                }{$h_subject:}}\n\
                  X-Delivered-To: $original_local_part@$original_domain
($local_part@$domain)\n\
                  X-Message-Age: $message_age"