Thanks John. This solves the problem of closing idle ones. How do I re-establish a connection on subsequent calls to $dbh?
From: John Scoles [mailto:byter...@hotmail.com] Sent: Saturday, February 02, 2013 11:01 PM To: Manikantan, Madhunapanthula_Naaga; dbi-dev@perl.org Subject: RE: Handling idle database connections you might wan to try visit_handles http://search.cpan.org/~timb/DBI-1.623/DBI.pm#visit_handles and visit_child_handles http://search.cpan.org/~timb/DBI-1.623/DBI.pm#visit_child_handles Send a code ref down the pipe and close the ones that have been idle for a while. Just a though. > From: > madhunapanthula.naaga.manikan...@deshaw.com<mailto:madhunapanthula.naaga.manikan...@deshaw.com> > To: dbi-dev@perl.org<mailto:dbi-dev@perl.org> > Subject: FW: Handling idle database connections > Date: Sat, 2 Feb 2013 13:09:03 +0000 > > DBI-dev , can you please take a look and opine? > > Thanks a lot !! > Manikantan > > _____________________________________________ > From: Manikantan, Madhunapanthula_Naaga > Sent: Saturday, January 26, 2013 1:31 AM > To: 'dbi-us...@perl.org' > Subject: Handling idle database connections > > > Hello dbi-users, > > I have a ton of PERL scripts that open a database connection, do some > database related work for 5 to 10 mts and go on with other work for 2 to 3 > days. This means, the database connection will be idle after 5 mts but still > exists for 2-3 days. This can potentially choke my server once all the > available threads are consumed. I think the right approach is for the > developer to disconnect once he is done with database work. Since I have no > control over the scripts, I want to explore the below. > > I was wondering if there is any option to DBI that will say " if the > connection is idle for say 'X' mts disconnect automatically and set state > accordingly. On subsequent call to $dbh it can check the state and > re-establish connection as necessary". > > This will alleviate lot of my issues and any help/suggestion in this regard > is greatly appreciated !!! > > Thanks a lot !!! > Manikantan. >