in reply to DBI keep alive

MySQL dropping connections is a frequent problem, so much so that the DBD::mysql driver has that feature built-in to reconnect. It looks like you fund that feature and have it enabled and working in the example.

You gave an example of it working, so that doesn't give us much to figure out the one that doesn't work. One thing that prevents the auto-reconnect is if you left a transaction open. DBD::mysql can only retry one query after auto-reconnect, so it can't get a new transaction back to the state it was in before the disconnect, so it doesn't try.

For web apps, if DBD::mysql isn't reconnecting automatically, you could call eval { $conn->ping } at the start of the request, and you could even call ->connect again if that fails.

As it happens, just about 3 weeks ago I was trying to *disable* the mysql auto-reconnect because I wanted to know when there was a new connection ID, to have the ability to log and kill long-running queries associated with a user account. Setting {mysql_auto_reconnect}= 0 had no effect. I didn't get around to reporting that bug yet. Maybe that bug is related to the problem you're having on Debian.