XF 1.2 MySQL Server has gone Away


Well-known member
I get this error when rebuilding attachment thumbnails:
An exception occurred: Mysqli prepare error: MySQL server has gone away in /home/brogan/public_html/xenforo/library/Zend/Db/Statement/Mysqli.php on line 77

    Zend_Db_Statement_Mysqli->_prepare() in Zend/Db/Statement.php at line 115
    Zend_Db_Statement->__construct() in Zend/Db/Adapter/Mysqli.php at line 381
    Zend_Db_Adapter_Mysqli->prepare() in Zend/Db/Adapter/Abstract.php at line 478
    Zend_Db_Adapter_Abstract->query() in Zend/Db/Adapter/Abstract.php at line 825
    Zend_Db_Adapter_Abstract->fetchOne() in XenForo/Error.php at line 55
    XenForo_Error::unexpectedException() in XenForo/Application.php at line 363
I'm using Imagick, and I have 'wait_timeout' default and 'max_allowed_packet' set to 64M.

What can I do to fix this?


Well-known member
P: I get an error when attempting to load a page and it states "MySQL server has gone away".
S: This is an issue with your server and something your host will be the best to help you solve. If you attempt to reload the page/rerun the task you received the error on, it is a possibility that it will be successful. Here are some related links to this specific error:



XenForo developer
Staff member
You may want to try building significantly fewer per page.


Well-known member
It's an unmanaged VPS and I'll retry building with less items per page.


Well-known member
Ok I changed it to 10 per page and the error happens even faster now. What's weird is that php-fpm hogs all my ram during the process. I changed it from dynamic to static but it still happens.
This error is flooding my MySQL error log files:
131115  9:42:49 [Warning] Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE  on a table with more than one UNIQUE KEY is unsafe Statement: INSERT INTO xf_deferred

                                (execute_class, execute_data, unique_key, manual_execute, trigger_date)
                                ('AttachmentThumb', 'a:2:{s:5:\"batch\";s:2:\"10\";s:8:\"position\";i:344;}', 'RebuildAttachmentThumb', '1', '1384526474')
                        ON DUPLICATE KEY UPDATE
                                execute_class = VALUES(execute_class),
                                execute_data = VALUES(execute_data),
                                manual_execute = VALUES(manual_execute),
                                trigger_date = VALUES(trigger_date)
Last edited:


XenForo developer
Staff member
Annoyingly, where you're getting the error is actually hiding the real error. We're supposed to be suppressing that second error but it doesn't seem to want to work.

If you submit a ticket with ACP and FTP details, I can have a look.

Regarding the other warning, that's either safe to ignore or you could change your binlog format (row vs statement logging).