[Mimedefang] Playing with -X and -P for Ticks

David F. Skoll dfs at roaringpenguin.com
Mon Oct 22 16:41:02 EDT 2012


On Mon, 22 Oct 2012 16:32:24 -0400
"Kevin A. McGrail" <KMcGrail at pccc.com> wrote:

> Anyone have any guidance on settings for -P and -X in order to
> maintain persistent DB connections?

Yeah, don't.  Because it won't work (as you no doubt discovered. :))

You have no idea which slave will handle the ticks.  Some slaves might
never get a tick.

You will have to wrap your DB functions with something that tests the DB
connection and reopens it if necessary.  The logical place to do that
would be right at the beginning of filter_sender, filter_recipient,
filter_begin, etc.... whichever callbacks you care about.

The logic will be something like:

# Assume $dbh is global

sub check_db_handle {
    if (!$dbh->ping()) {
        # reopen DBH
        if (!$dbh->ping()) {
            # AARGH!  Tempfail?
        }
    }
}

(Also, SQL client timeouts are totally evil.  Don't use them.  If your
DB can't handle lots of connections, use a connection pooler.)

Regards,

David.



More information about the MIMEDefang mailing list