The SQL server keeps a connection to the client open for a limited period of time. In the early days of Apache::DBI, everyone was bitten by the so-called morning bug—every morning the first user to use the site received a "No Data Returned" message, but after that everything worked fine.
The error was caused by Apache::DBI returning an invalid connection handle (the server had closed it because of a timeout), and the script was dying on that error. The ping( ) method was introduced to solve this problem, but it didn't work properly until Apache::DBI Version 0.82 was released. In that version and after, ping( ) was called inside an eval block, which resolved the problem.
It's still possible that some DBD:: drivers don't have the ping( ) method implemented. The Apache::DBI manpage explains how to write it.
Another solution is to increase the timeout parameter when starting the database server. We usually start the MySQL server with the script safe_mysqld, so we modified it to use this option:
nohup $ledir/mysqld [snipped other options] -O wait_timeout=172800
The timeout value that we use is 172,800 seconds, or 48 hours. This change solves the problem, but the ping( ) method works properly in DBD::mysql as well.
 
Continue to: