On Wed, 2006-02-01 at 14:06 -0800, Tyler MacDonald wrote: > What if you > can't ping the connection because of a temporary TCP/IP problem [...] > And here's some more conjecture: What if the ping just times out > because the server is really, really busy?
DBI will replace it, removing all references to the one that failed to ping, and it will go out of scope and get DESTROY'ed. > I don't know if it does an explicit disconnect() itself in this > case, but I do know the handle reference (which is essentally garbage at > this point) is left laying around. When is this? DBI checks the handle when you call connect_cached, and if it fails to ping, the old one is replaced in the cache and sent off to garbage collection. If it isn't getting garbage-collected, that probably means you have it in global or closure somewhere. > > I issue a rollback on all active connections at the end of every request. > > Everyone who uses transactions at all should do that. > > I wrote DBIx::Transaction specifically so I wouldn't have to worry > about that anymore. ;-) It's so much easier just to > > $dbh->transaction(sub { > ... > return $do_i_want_to_commit ? 1 : 0; > }); > > especially now that I can nest them arbitrarily deep. If you wrap those in an eval and never do anything outside of one, it should work. I personally avoid doing things in sub refs because it caused so many problems for me when using Error's try/catch syntax. > Yeah, I ditched Apache::DBI early in diagnosing this problem. Then I > wrote that hack to solve it, which is what has started this whole thread. I > was happy just posting the hack and leaving it at that, but you guys keep > egging me on ;-) Well, the hack may work for you, and that may be all that matters in your case, but I don't think it's right to make other people think they need to use that instead of Apache::DBI or connect_cached. > They were done one at a time. To the best of my memory: Sorry, I can't make a useful guess based on this. For one thing, you would need to do them separately, in order to know which ones made the difference. - Perrin