[Mimedefang] Mail::SpamAssassin::BayesStore::SQL databasepersistence.

Matthew Schumacher matt.s at aptalaska.net
Wed Jul 20 11:51:00 EDT 2005


Matthew.van.Eerde at hbinc.com wrote:
> schu wrote:
> 
>>So the question is, is there a way to make SA use persistent
>>connections?  I read though the docs and didn't see anything. 
>>Perhaps a way to create a persistent connection in MD and pass it to
>>the SA module? 
> 
> 
> Some thoughts...
> 
> 1. spamd
> spamassassin calls through the "spamassassin" command and the Mail::SpamAssassin perl modules don't live long enough to hold on to a persistent connection.  But spamd threads do.
> 
> 2. connection pooling
> Perhaps a "middle layer" could be developed, consisting of a daemon that does nothing but relay connection info - each connection could be kept open for a certain time after it is nominally closed.  If a request for a new connection comes in, surviving connections could be reused.  Windows has an option to do this for ODBC connections on a per-driver level.
> 

It looks like the code is supposed use persistent connections:

>From SpamAssassin/BayesStore/SQL.pm on line 134
==================================================================
  return 1 if ($self->{_dbh}); # already connected

  my $main = $self->{bayes}->{main};

  $self->read_db_configs();

  # Turn off PrintError and explicitly set AutoCommit to off
  my $dbh = DBI->connect($self->{_dsn}, $self->{_dbuser}, $self->{_dbpass},
                         {'PrintError' => 0, 'AutoCommit' => 1});

  if (!$dbh) {
    dbg("bayes: Unable to connect to database: ".DBI->errstr());
    return 0;
  }
  else {
    dbg("bayes: Database connection established");
  }

  $self->{_dbh} = $dbh;
==================================================================

So the question is why doesn't it work?  Does anyone know if this works
when using spamd?

schu



More information about the MIMEDefang mailing list