Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
frobHere 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.
Comment #2
joachim CreditAttribution: joachim commented> General error: 2006 MySQL server has gone away
That's a problem with your environment.
Comment #3
frobWhat 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?
Comment #4
frobThis is likely a core issue. I have added some refinement to my PDO settings.
Now the site loads and the PDO doesn't go away, however the menu is now gone.
Comment #5
Ada Hernandez CreditAttribution: Ada Hernandez at MTech, LLC commentedI added this in
in my.cnf and works for me.
Comment #6
xcusso CreditAttribution: xcusso as a volunteer commentedI had the same problem, #5 works for me.
Comment #7
Jon Sh CreditAttribution: Jon Sh commentedIt 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
Comment #8
Codenext CreditAttribution: Codenext as a volunteer commentedIs 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