You are here:  » MySQL server has gone away

Support Forum



MySQL server has gone away

Submitted by marco@flapper on Fri, 2012-03-16 08:14 in

Hi,
I got this problem again.

I have the SESSION wait_timeout mod. Initially set on 900 and then changed to 4000. But in both cases I got the Mysql server has gone away warning.

I ran the cron job with database debug on and I saw:
PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/myaccount/public_html/includes/database.php on line 29
PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/myaccount/public_html/includes/database.php on line 34

I can sent you the complete cron message if you want?

This is my modified database.php:
{code saved}

Submitted by support on Fri, 2012-03-16 08:52

Hello Marco,

I recall previously trying to use mysql_ping() but that appeared to be affected by the same issue so it just occurred to me that a simple solution would be to execute a dummy query (e.g. "SELECT 1") and if that fails then establish the link.

In your includes/database.php, within the database_queryModify() function REPLACE the following line:

$link = @mysql_connect($config_databaseServer,$config_databaseUsername,$config_databasePassword);

with:

global $link;
if (!@mysql_query("SELECT 1",$link))
{
  $link = @mysql_connect($config_databaseServer,$config_databaseUsername,$config_databasePassword);
}

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by marco@flapper on Fri, 2012-03-16 11:17

Hi,
Not working. Still get the mysql server has gone away.

I noticed the error occurs at the second feed. The first feeds gets imported. The second feed I have a Drop Record If Not RegExp filter on an additional index field (see http://www.pricetapestry.com/node/4543).

I remember that I imported this specific feed yesterday without the filter and that it imported then. But now when I cronjob import it with the filter I get the Mysql server has gone away error.

Submitted by support on Fri, 2012-03-16 13:01

Hi Marco,

Please could you email me the log and latest includes/database.php and I'll check it out...

Cheers,
David.
--
PriceTapestry.com