WordPress – MySQL server has gone away

I have a WordPress install on a dedicated server with decent memory (upwards of 8GB).

The WordPress install includes many plugins – 50 active plugins. Most important to note is the WPML plugin to make WordPress multilingual. The theme is Weaver II Pro.

Read More

The stack is LAMP – CentOS 6.3, Apache 2.4.4, Percona MySQL, PHP-FPM.

I have been quite stupid, and didn’t set up a test or staging server.

Everything was running fine till I updated to WordPress 3.8, and also updated several plugins at the same time.

I didn’t pay attention at the time, but all my widgets got messed up, and so did any sort of navigation etc.

I enabled error_log for a bit, i.e.

ini_set('log_errors',TRUE);
ini_set('error_reporting', E_ALL);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');

This resulted in an immense file – basically the error_log grows by about a GB every 4 minutes or so.

The primary error I found in the error log was database server disconnect, better known as

MySQL server has gone away

The first priority was to patch the problem. So I installed Database Ping plugin. This mostly, though not completely solved the issue. Many of the widgets came back.

However, the special (non-English) characters are all messed up (converted to question marks). I tried to fix this by opening wp-mysql-ping.php and commenting out

if ( !DB_CHARSET && version_compare(mysql_get_server_info($this->dbh), '4.1.0', '>='))
                                    {
                                        $this->query("SET NAMES '" . DB_CHARSET . "'");
                                    }

Didn’t help.

Besides, the plugin is not a permanent or complete solution. So leaving the site in this messed up state, I started working on other possibilities:

As suggested at Rackspace, I edited my.cnf to add

wait_timeout = 60

Didn’t help.

Also added caching to my.cnf

query_cache_type = 1
query_cache_limit = 8M
query_cache_size = 512M

Didn’t help.

(and yes, I restarted mysql every time I edited my.cnf)

Also tried the method suggested here:
In wp-db.php
before

$this->select( $this->dbname, $this->dbh );

I added

$this->query("set session wait_timeout=600" );

Didn’t help.

I’m at my wit’s end. Please help!

Related posts

Leave a Reply

1 comment