Skip Menu |
 

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 35942
Status: resolved
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: libithashanmugam [...] yahoo.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.08010
Fixed in: (no value)



Subject: Connections remain open even when out of scope
Download (untitled) / with headers
text/plain 1.7k
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 remain open. 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.08010 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 720. 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 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
Subject: Re: [rt.cpan.org #35942] Connections remain open even when out of scope
Date: Fri, 16 May 2008 16:36:12 +0100
To: bug-DBIx-Class [...] rt.cpan.org
From: "Will Hawes" <wdhawes [...] gmail.com>
Download (untitled) / with headers
text/plain 2.2k
2008/5/16 lisha via RT <bug-DBIx-Class@rt.cpan.org>: Show quoted text
> > Fri May 16 08:57:53 2008: Request 35942 was acted upon. > Transaction: Ticket created by lisha > Queue: DBIx-Class > Subject: Connections remain open even when out of scope > Broken in: 0.08010 > Severity: Critical > Owner: Nobody > Requestors: libithashanmugam@yahoo.com > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=35942 > > > > 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 remain open. 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.08010 > 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 720. > > 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 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 >
Maybe: $schema->storage->disconnect(); ???
From: libithashanmugam [...] yahoo.com
Download (untitled) / with headers
text/plain 2.6k
On Fri May 16 11:38:24 2008, WDH wrote: Show quoted text
> 2008/5/16 lisha via RT <bug-DBIx-Class@rt.cpan.org>:
> > > > Fri May 16 08:57:53 2008: Request 35942 was acted upon. > > Transaction: Ticket created by lisha > > Queue: DBIx-Class > > Subject: Connections remain open even when out of scope > > Broken in: 0.08010 > > Severity: Critical > > Owner: Nobody > > Requestors: libithashanmugam@yahoo.com > > Status: new > > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=35942 > > > > > > > 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 remain open. 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.08010 > > 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 720. > > > > 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 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 > >
> > Maybe: > > $schema->storage->disconnect(); > > ???
Does this mean DBIx will not do disconnects automatically? Do we have to do it explicitly in our code? Could you please clarify whether explicit disconnect is a workaround or a solution?
Download (untitled) / with headers
text/plain 186b
Please ask for support via the list; your script does not reproduce the issue on any database I have access to so it's almost certainly a problem with your setup. Ticket marked rejected.
From: libithashanmugam [...] yahoo.com
Download (untitled) / with headers
text/plain 947b
On Wed May 28 16:25:36 2008, MSTROUT wrote: Show quoted text
> Please ask for support via the list; your script does not reproduce the > issue on any database I have access to so it's almost certainly a > problem with your setup. Ticket marked rejected.
Hi, When doing a trace of version 0.07002 of DBIx::class which doesn't have the issue and the current version, I found a code change in DBIx/Class/Storage/DBI.pm. The latest version has one additional statement in sub '_verify_pid' of DBIx/Class/Storage/DBI.pm. $self->_dbh->{InactiveDestroy} = 1; From DBI docs, I understand that if this flag is not set, the dbi handle will be destroyed when last reference is removed. If it set, then it means 'treat the handle as not-Active in the DESTROY method'. Commenting the statement solves the issue I face. But, I am not sure about the consequences of it. Could someone tell me what is the significance of having this statement in this file? Thanks, Libitha
Subject: Re: [rt.cpan.org #35942] Connections remain open even when out of scope
Date: Sun, 20 Jul 2008 00:00:25 +0100
To: lisha via RT <bug-DBIx-Class [...] rt.cpan.org>
From: Matt S Trout <mst [...] shadowcat.co.uk>
Download (untitled) / with headers
text/plain 1.8k
On Fri, Jul 04, 2008 at 06:08:53AM -0400, lisha via RT wrote: Show quoted text
> Queue: DBIx-Class > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=35942 > > > On Wed May 28 16:25:36 2008, MSTROUT wrote:
> > Please ask for support via the list; your script does not reproduce the > > issue on any database I have access to so it's almost certainly a > > problem with your setup. Ticket marked rejected.
> > Hi, > When doing a trace of version 0.07002 of DBIx::class which doesn't have > the issue and the current version, I found a code change in > DBIx/Class/Storage/DBI.pm. > > The latest version has one additional statement in sub '_verify_pid' of > DBIx/Class/Storage/DBI.pm. > > $self->_dbh->{InactiveDestroy} = 1; > > From DBI docs, I understand that if this flag is not set, the dbi handle > will be destroyed when last reference is removed. If it set, then it > means 'treat the handle as not-Active in the DESTROY method'. > > Commenting the statement solves the issue I face. But, I am not sure > about the consequences of it. Could someone tell me what is the > significance of having this statement in this file?
That's to make sure when you fork() that the child process doesn't close the parent's opened database handle. So what I think must be happening is that you're forking having already connected the $schema and then not freeing the copy in the parent. As I said previously, -please- subscribe to the mailing list at http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class and post your application code there if you want help debugging it. This is -not- a DBIx::Class bug. -- Matt S Trout Need help with your Catalyst or DBIx::Class project? Technical Director http://www.shadowcat.co.uk/catalyst/ Shadowcat Systems Ltd. Want a managed development or deployment platform? http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
From: libithashanmugam [...] yahoo.com
Download (untitled) / with headers
text/plain 488b
Hi Matt, This seems to be an issue with DBIx::Class::Storage::DBI::ODBC. Another bug has been opened for this issue http://rt.cpan.org/Public/Bug/Display.html?id=38186 Diff of working version (0.07002) and latest version of ODBC.pm shows that $self->_dbh has been replaced with $self->dbh in _rebless() in the latest version of ODBC.pm. I made the change and it resolves the issue. Marc has checked in the fix. Will wait for the release of next version of DBIx::Class. Thanks, Libitha
Download (untitled) / with headers
text/plain 335b
Closing tickets http://rt.cpan.org/Ticket/Display.html?id=38186 http://rt.cpan.org/Ticket/Display.html?id=35942 http://rt.cpan.org/Ticket/Display.html?id=32654 as they all seem to be resolved by http://dev.catalyst.perl.org/svnweb/bast/revision/?rev=4750. Please test against latest dev release to confirm the problem is take care of.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.