perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard N. Fogle" <r...@neosaint.org>
Subject DBI persistence problem
Date Thu, 02 Dec 2004 01:00:30 GMT
Hello,

We're having quite the time with CGIs being called in mod_perl, listed
below is an example of the DBI connection code:

----SNIP----
use DBI
my $write_dbh =
DBI->connect("DBI:mysql:writeDB:192.168.1.10","foouser","foopass") ||
die $DBI::errstr;
my $read_dbh;
if ( int(rand(4)) ) { $read_dbh =
DBI->connect("DBI:mysql:readDB1::192.168.1.20","foouser","foopass") ||
se
tReadToWrite($read_dbh); }
else { $read_dbh =
DBI->connect("DBI:mysql:readDB2:192.168.1.21","foouser","foopass") ||
setReadToWrite($r
ead_dbh); }
----SNIP----

Basically, we have one MySQL cluster setup for reads and the other
cluster for writes - the reads cluster alternates between master and
slave.  This works fine.  The problem we're having is each time the CGI
is called it seems to make a persistent connection to the database
despite the fact that we have a $dbh->disconnect(); at the end of the
code.  This causes the application to work well for a period of time,
but it will quickly run the databases out of processes (despite raising
max_connections to 1024+) and when we go into MySQL to look at the
process list it shows a bunch of sleeping connections!  

We have no real explanation other than perhaps mod_perl, or our (mis)use
thereof, may be adding to this.  We have mod_perl loaded in apache but
nothing in our startup.PL, nor anything special in httpd.conf.
Appreciate it if anyone has had this problem in the past and could shed
some light on what is going on.  This is a very high-load application
and there is no way the webservers would survive without mod_perl.  The
server-side app consists of about 20 scripts, each with their own
connect string as described above and their own disconnect strings.  We
tried placing the connect strings in startup.PL and into a seperate file
that gets shared but that just drives the load average through the roof.
Appreciate any assistance anyone could provide, is mod_perl caching
these scripts and making the database connections persistent?

Regards,

Rich




Mime
View raw message