develooper Front page | perl.dbi.users | Postings from December 2012

Re: Possible database handle leak in DBI?

Thread Previous | Thread Next
From:
Greg Sabino Mullane
Date:
December 5, 2012 02:34
Subject:
Re: Possible database handle leak in DBI?
Message ID:
ebd6f87181d2865cfd1544ce3676abd6@biglumber.com

-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

Duncan McEwan wrote:
> Our application uses the DBI connect_cached() method so that it can reuse
> a persistent database connection for each invocation.
...
> Unfortunately I don't understand DBI.pm well enough to know how an item
> could drop out of the cache while the corresponding database connection
> remains active.

So to summarize, you are seeing that sometimes connect_cached uses 
a previous entry, and sometimes it does not, right? If it does it 
every time, then something is preventing the cache from being used 
at all, but it sounds like it is an occasional event. When the 
connect_cached fails with a false negative, it is because the CachedKids 
hash is empty, when it should have at least one existing item, right?

I'd bump up the trace level to at least 3, or at least check out the 
clear_cached_kids function inside of DBI.xs and get some debugging 
there to see who is clearing that cache. As far as DBI itself, I 
think only destroying a handle will call that function, and that 
function is the only thing that will empty out {CachedKids}. It's 
possible that the cache is getting cleared before the database handle 
truly dies and does a full disconnect.

I don't see any mention of CachedKids or clear_cached_kids inside 
DBD::mysql, so we can probably rule that out. The other thing to 
consider is the web app. I know that Apache::DBI / modperl has a 
lot of special rules regarding connecting and reconnecting: it's 
possible your fastcgi does as well.

You might also want to poke around with the mysql_auto_reconnect 
setting; it's possible it is on and causing issues.

- -- 
Greg Sabino Mullane greg@turnstep.com
End Point Corporation http://www.endpoint.com/
PGP Key: 0x14964AC8 201212042128
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8

-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAlC+soAACgkQvJuQZxSWSshEwgCeJbBDVbqNRrBNMhpP2oDOws4T
z18AnjLPJAPUgLVZj/DUxcd7mYIzlGuP
=9O+A
-----END PGP SIGNATURE-----



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About