Actually, last time I checked, the DBI, DBD code was not officially thread-safe, so in my threaded prog I had a separate cxn in each thr. Worked a treat.
As mentioned, if there's a long enough break between SQL statements (in a given cxn) it'll timeout.
In MYSQL use
show variables;
the last line looks like this
| wait_timeout | 28800
that's in seconds. You amend that in the my.conf file, or catch the SQL (which you should be doing anyway) and check for the explicit error:
Code:
# Check if real SQL error or DB gone away
if( $cfg::dbh->errstr =~ /MySQL server has gone away/ )
{
# Try to re-connect for later
$error_msg = "db_update_active(): ".localtime()." ".
$cfg::dbh->errstr;
db_connect();
}