When I do enable the Admin Menu (28 Sep. build) I get the following error. If I do delete the admin_menu folder the site work again.

Additional uncaught exception thrown while handling exception.

Original

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.source = :source AND s.context = :context AND s.textgroup = 'default'; Array ( [:language] => de [:source] => Configure how content input by users is filtered, including allowed HTML tags. Also allows enabling of module-provided filters. [:context] => ) in locale() (line 676 of /home/www/teqyo/modules/locale/locale.module).

Additional

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.source = :source AND s.context = :context AND s.textgroup = 'default'; Array ( [:language] => de [:source] => The website encountered an unexpected error. Please try again later. [:context] => ) in locale() (line 676 of /home/www/teqyo/modules/locale/locale.module).

CommentFileSizeAuthor
#7 6133642_mysqlbuffer_7.patch734 bytestomogden

Comments

petsagouris’s picture

How can someone reproduce this?

sun’s picture

Status: Active » Closed (cannot reproduce)

This error is not related to or caused by admin_menu. It typically means that your max_allowed_packet_size setting for MySQL is too small. The error will also appear for any other additional module you install.

Ideally, search the net for "Drupal MySQL server has gone away error on module installation"

tomogden’s picture

Actually, I get this error with my memory allowances set at all different sizes, as well as totally maxed out. And no, it does not happen on just any other module within the environment.

However, I do think this is an issue that originates outside this module because I've been able to reproduce it with a couple of other operations. In this particular site I can also get this error when I try to create a new Feature at /admin/structure/feature/create. When I trace the error, it occurs with a caching function in the menu object, and I can correlate the same function failure with this module.

Again, I think it's a cause outside this module, perhaps corrupt data, but I'm still looking for the cause.

The system I'm using is an AWS CloudFormation stack with RDS database.

tomogden’s picture

Okay, here's the problem:

This could be a memory issue, but not PHP memory as a whole. It could be the memory buffer allocated to PHP's PDOStatement class, which is used for executing all MySQL queries. By default this buffer is set to 1MB (1024x1024 characters), but some cache queries can easily top that limit. When the buffer is overloaded, PDO shuts down, and ALL database queries return an error.

Here's the solution:

Increase the buffer allowance to something larger, like 10MB. You can do that by entering a setAttributes statement in the PDOStatement object, like so.
$this->setAttribute(PDO::MYSQL_ATTR_MAX_BUFFER_SIZE, 1024*1024*10);

DON'T try to turn off buffering. While this can work in limited situations, it is likely to throw more errors on most of your Drupal pages.

ONCE AGAIN, this is NOT an issue with admin_menu module, although it is more likely to happen in this association. However, we need to look into treating this in core.

perignon’s picture

Status: Closed (cannot reproduce) » Fixed

@tomogden Mind pointing me to where you added the PDO setAttr statement? Was it in database.inc?

DrupalDan’s picture

sub

tomogden’s picture

StatusFileSize
new734 bytes

The best place to put it is in the PDO constructor of the the MySQL driver, which is at /includes/database/mysql/database.inc. Patch included, but keep in mind this is just a kluge for now and does not resolve all cases.

DrupalDan’s picture

Hi tomogden, thanks for the patch. I run into the "MySQL server has gone away" problem a couple of times after installing and enabling one module or the other. Currently, I'm experiencing the problem with the following error messages:

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT menu_links.* FROM {menu_links} menu_links WHERE (module = :db_condition_placeholder_0) AND (router_path = :db_condition_placeholder_1) ; Array ( [:db_condition_placeholder_0] => system [:db_condition_placeholder_1] => admin/config/content ) in admin_landing_page_access() (line 164 of C:\wamp\www\sites\all\modules\admin\admin.module).

Can you tell me what's the cause of this error? And do you think the patch will fix this? I'd love to try and see how it goes but I'm still looking for some information about how to patch a inc file, as I only know to patch a module and I guess that's a little different.

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jason.fisher’s picture

Why is this fixed/closed? Shouldn't this be moved to core?

tomogden’s picture

Yes, indeed, but I'm not sure where in core to post it. If you would like to initiate an issue there, I would appreciate it.

ehsankhfr’s picture

Issue summary: View changes

#4 is completely right!

On my local development workstation this error appears:

Additional uncaught exception thrown while handling exception.

Original

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT * FROM {menu_links} WHERE menu_name = :menu_name AND module = :module AND link_path = :path; Array ( [:menu_name] => management [:module] => system [:path] => admin ) in toolbar_get_menu_tree() (line 286 of /Applications/MAMP/htdocs/*********/modules/toolbar/toolbar.module).

...

But on the web server it doesn't appear!

So it's a memory related issue!

Chris Charlton’s picture

This ticket is closed but there wasn't a follow up link or anything resolvable. Bump.

deanflory’s picture

I'm getting an error with #7 patch:

6133642_mysqlbuffer_7.patch

patching file includes/database/mysql/database.inc
patch unexpectedly ends in middle of line
Hunk #1 succeeded at 50 with fuzz 2 (offset 4 lines).

Very odd. Did it succeed or did it not?