Drupal : Problems with Database Timeout Query

Have you ever found this error in your site ?

[27-Jul-2007 06:38:19] PHP Warning: MySQL server has gone away query: INSERT INTO watchdog (uid, type, message, severity, link,
location, referer, hostname, timestamp) VALUES (0, 'php', 'MySQL server
has gone away\nquery: SELECT data, created, headers, expire FROM cache
WHERE cid = 'menu:0:en' in /home/hamburgi/public_html/orvwatch/includes/database.mysql.inc on line
121.', 2, '', 'http://www.orvwatch.com/pages/get_signs.html', '',
'', 1185539899) in /home/hamburgi/public_html/orvwatch/includes/database.mysql.inc on line

I found it today in one of my sites. It occur when I try to open menu in Site Building and Site Configuration menus. Seems there are connection problem between my site (using drupal) and MySQL server. Someone in drupal forum guessing this maybe because two problems, which result in the same error:

1. Timeout (in my case): There I think it's a general problem of the drupal database connection handling. This error occurs as soon as a function runs longer than the db connection timeout setting (this may vary from host to host) without db interactions and the host turned of auto-reconnect. This can happen in every module. The solution could be a manual reconnect of the drupal db handler or where possible to set auto-reconnect in php.ini.

2. Large Queries: I'm not sure if this happens. But there may be too large queries by some drupal modules which exceed the query-size limit.

And I am guessing number one is exactly the same problem I had with my site.

Change the php.ini, said someone in Drupal Forum. But how to change it because we dont have any access to change php.ini. But not for me, the hosting administrator had give php.ini file in every sites he hosted. Edit my php.ini, add this line :

memory_limit = 16M
mysqli.reconnect = On

And it works. mysql.reconnect means drupal sites will attempt to reconnect to MySQL databases even it had long query. Someone in drupal forums give another solutions, edit MySQL configuration file , my.ini file and change the value of max_allowed_packet :


Good luck