Problem/Motivation

Some Entities for some reason cause PDO Exceptions, this looks to be related to the user_module function user_roles and the session_api
For me this happens with node and comment entities. However, there have been several issues posted for the same issue with other entity types being fixed by some work arounds like enabling/disabling/feature rebuilding/standing on head.

I currently do not have a workaround.

Full Error

Additional uncaught exception thrown while handling exception.

Original

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT r.rid AS rid, r.name AS name FROM {role} r ORDER BY weight ASC, name ASC; Array ( ) in user_roles() (line 2923 of /modules/user/user.module).

Additional

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT ff.* FROM {filter_format} ff WHERE (status = :db_condition_placeholder_0) ORDER BY weight ASC; Array ( [:db_condition_placeholder_0] => 1 ) in filter_formats() (line 426 of /modules/filter/filter.module).

Uncaught exception thrown in session handler.

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT 1 AS expression FROM {sessions} sessions WHERE ( (sid = :db_condition_placeholder_0) AND (ssid = :db_condition_placeholder_1) ); Array ( [:db_condition_placeholder_0] => -F2LoaJZu994OC_EaM2-zo18NfBquFs9Lr29R2biF14 [:db_condition_placeholder_1] => ) in _drupal_session_write() (line 209 of /includes/session.inc).

Proposed resolution

Still debugging

Remaining tasks

Debug

Comments

frob’s picture

Here is an update for this.

My local dev is osx with nginx and mariadb.

My remote dev server is cent with apache and mysql.

My local dev gets the error and my remote dev doesn't. This could be some very strange environmental issue that the flag module is some how creating the perfect environment for.

joachim’s picture

> General error: 2006 MySQL server has gone away

That's a problem with your environment.

frob’s picture

What is the problem? What could cause this. I have not been able to figure out any explanation as to why this is happening.

I agree that this issue is likely environmental, however what settings could account for this?

frob’s picture

Project: Flag » Drupal core
Version: 7.x-3.x-dev » 7.x-dev
Component: User interface » database system
Category: Bug report » Support request

This is likely a core issue. I have added some refinement to my PDO settings.

ATTR_TIMEOUT = 2.0
and 
MYSQL_ATTR_COMPRESS = 1

Now the site loads and the PDO doesn't go away, however the menu is now gone.

Warning: Error while sending QUERY packet. PID=50053 in DatabaseStatementBase->execute() (line 2171 of  
/includes/database/database.inc).
Notice: Trying to get property of non-object in shortcut_preprocess_page() (line 665 of  
/modules/shortcut/shortcut.module).
Warning: Invalid argument supplied for foreach() in shortcut_preprocess_page() (line 665 of  
/modules/shortcut/shortcut.module).
Notice: Trying to get property of non-object in shortcut_preprocess_page() (line 675 of  
/modules/shortcut/shortcut.module).
Notice: Trying to get property of non-object in shortcut_preprocess_page() (line 676 of  
/modules/shortcut/shortcut.module).
Ada Hernandez’s picture

I added this in

[mysqld]
max_allowed_packet = 100M

in my.cnf and works for me.

xcusso’s picture

I had the same problem, #5 works for me.

Jon Sh’s picture

It didn't solved for me.

I remember that this was caused after i tried to clone on of the flags (node flag), by changing some infos in the array.
And from now on, whenever i try to clone or create new node flag this error happens.
I use Apache/2.4.6 (CentOS) PHP/5.4.16 Zend Engine v2.4.0 5.5.47-MariaDB

Codenext’s picture

Is there any permanent solution for this issue? i did see another post also https://www.drupal.org/node/1795430. Probably both are the same issue. It will be good if there is any permanent solution for this. Very thanks