Subject: | DB handles don't get disconnected even when they go out of scope |
Date: | Fri, 25 Jan 2008 11:44:37 -0800 (PST) |
To: | bug-DBIx-Class [...] rt.cpan.org |
From: | sowmya swaminathan <astra_here [...] yahoo.com> |
Hi,
I have a function which makes a DBIx connect, does some search and returns the results. I have a daemon which repeatedly calls this function once in few seconds. What I observed is that even after function call is done, the DB connections don't close. The connections stays alive and keep increasing and as the max connections limit is reached, the daemon dies because new connection fails. Once the process exits, all the connections get closed and new connections can be made after that. Earlier, I was using DBIx Class 0.07002 and I didn't have this problem.
DBIx Class version: 0.08008
Perl version: 5.8.7
Operating system vendor and version: Linux (Red Hat Enterprise Linux AS release 3), 2.4.21-37.0.0.4.ELhugemem
Error message:
==========
DBI connect('testcs','test',...) failed: [unixODBC][TimesTen][TimesTen 7.0.1.0.0 ODBC Driver][TimesTen]TT0702: Connect failed because max number of connections exceeded (max 2048) -- file "db.c", lineno 9050, procedure "sbDbConnect" (SQL-HY000)(DBD: db_login/SQLConnect err=-1) at /usr/local/perl/5.8.7/lib/DBIx/Class/Storage/DBI.pm line 839
Can't call method "resolve" on an undefined value at /usr/local/perl/5.8.7/lib/DBIx/Class/Row.pm line 707.
I tried the same with oracle database and found the same issue.
Sample code which can reproduce the issue:
==============================
sub connect_to_db {
my $schema = SchemaClass->connect();
}
for (my $i = 0; $i < 10; $i++) {
connect_to_db();
}
print "Press enter to quit\n";
my $key = <STDIN>;
You can check the number of active connections and before providing input to quit.
In my case there 6 active connections before running the script and 16 when the script prompted for input.
Could someone provide a solution to this issue?
Thanks
Show quoted text
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs