in reply to MySQL server has gone away

Personally I have never tried setting the attribute that Liz is suggesting, in general I am leary of things like that while using Apache::DBI. I feel that I am already giving up enough control over my connections to that module, to also allow automatic reconnects just leaves me uneasy. Maybe I have just spent too much time hunting mod_perl/DBI connection bugs.

While I agree with sheep that this sounds something like the MySQL morning bug. I have seen other issues with DBI/DBD::mysql while using Apache::DBI and mod_perl where connections can seem to disappear (and then leak memory like crazy). I found this bug/issue on Win32 with Apache 2 & mod_perl 1.99 (yes, yes, I know its not even alpha, but I was forced into using it), but during my research I saw others having similar issues on Linux systems as well.

I was able to solve my lost-connection/memory-leak issue by simply adding this code at the top of every function that was passed a DBI connection.

$dbh ||= DBI->connect("connection string", "username", "password");
Its pretty efficient as well since it uses the short circuit assignment. The right hand side wont get executed unless it needs to be, and it will not incur the overhead of entering and exiting a "if" block.

I know its kinda paranoid programming, but I find paranoia is a good thing when using both mod_perl and Apache::DBI.

-stvn