How to track down a Drupal max_allowed_packet error?
One of my staging sites has recently started spewing huge errors on every admin page along the lines of:
User warning: Got a packet bigger than 'max_allowed_packet' bytes query: UPDATE cache_update SET data = '
... ', created = 1298434692, expire = 1298438292, serialized = 1 WHERE cid = 'update_project_data' in _db_query() (line 141 of /var/www/vhosts/mysite/mypath/includes/database.mysqli.inc).
(where "..." is about 1.5 million characters worth of serialized data)
How should I go about tracking down where the error originates? Would adding开发者_如何转开发 debugging code to _db_query do any good, since it gets called so much?
No need to track this down because you can't fix it I think.
This is the cache from update.module, containing information about which modules have updated versions and so on. So this is coming from one of the "_update_cache_set()" calls in that module.
Based on a wild guess, I'd say it is the one in this function: http://api.drupal.org/api/drupal/modules--update--update.fetch.inc/function/_update_refresh/6
It is basically building up an huge array with information about all projects on your site and tries to store it as a single, serialized value.
How many modules do you have installed on this site?
I can think of three ways to "fix" this error:
- Increase the max_allowed_packet size. (max_allowed_packet setting in my.conf)
- Disable update.module (It's not that useful on a staging/production site anyway, when you need to update on a dev site first anyway)
- Disable some modules ;)
I had a similar error and went round and round for about an hour.
Increased memory limit to 512m
and still had the issue. And figured that was enough. So went looking elsewhere.
I cleared the caches with drush, still the error, and then looked at the database tables.
I noticed that all the cache tables were cleared except cache_update. I truncated this table and bam, everything was working normally.
Before I got the memory limit error, I got a max_input_vars
error since I am on PHP5.4
. But this question and answer led me to this fix. Not quite sure how or why it worked, but it did.
精彩评论