‘MySQL server has gone away‘ and ‘Lost connection to server during query‘ MySQL error messages are one of the more common encountered with vBulletin forums. The main reason being non-optimal MySQL server settings – usually the default my.cnf values for MySQL are in use or setting the wait_timeout value too low. A whole list of reasons for these MySQL error messages are listed here.
But the other day I came across another reason why these MySQL error messages may occur. If you run a control panel such as WHM / Cpanel, it has a set of default cronjobs which runs. One in particular is for /scripts/upcp which updates WHM/Cpanel versions and checks for version updates to components such as MySQL server. One vB client, kept getting a handful of these MySQL server has gone away errors around the same time each morning starting at around 5:14 am.
Database error in vBulletin 3.8.6:
SELECT postid, post.title, pagetext, post.threadid, thread.title AS threadtitle
FROM post AS post
INNERJOIN thread AS thread USING(threadid)WHERE postid =3160513;
MySQL Error : MySQL server has gone away
Error Number : 2006
Request Date : Tuesday, March 15th 2011 @ 05:14:38 AM
Error Date : Tuesday, March 15th 2011 @ 05:14:39 AM
Script : http://forumdomain.com/forums/editpost.php?do=updatepost&p=3160513
Referrer : http://forumdomain.com/forums/editpost.php?do=updatepost&p=3160513
IP Address : xxx.xxx.xxx.xxx
Username : mysqlusername
Classname : vB_Database
MySQL Version :
Turns out the /script/upcp cronjob is scheduled to start running at 5:14 am each morning and it was the peak or busy vBulletin forum activity time. So the solution for MySQL error messages, was to change the scheduled cronjob time for /script/upcp to a time which was off peak for the forums.