Uncaught exception thrown in session handler.
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in _drupal_session_write() (line 204 of C:\rnd\proprietary\rnd.emr.ph\drupal-7.x-dev\includes\session.inc).

os: ubuntu

Comments

keichee’s picture

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT b.* FROM {block} b WHERE (b.theme = :db_condition_placeholder_0) AND (b.status = :db_condition_placeholder_1) ORDER BY b.region ASC, b.weight ASC, b.module ASC; Array ( [:db_condition_placeholder_0] => bartik [:db_condition_placeholder_1] => 1 ) in _block_load_blocks() (line 708 of C:\rnd\proprietary\rnd.emr.ph\drupal-7.x-dev\modules\block\block.module).

os: ubuntu and windows

keichee’s picture

Logo Here
Error

The website encountered an unexpected error. Please try again later.
Error messagePDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT 1 AS expression FROM {cache_update} cache_update WHERE ( (cid = :db_condition_placeholder_0) ) FOR UPDATE; Array ( [:db_condition_placeholder_0] => update_project_data ) in _update_cache_set() (line 763 of C:\rnd\proprietary\rnd.emr.ph\drupal-7.x-dev\modules\update\update.module).
Uncaught exception thrown in shutdown function.
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: DELETE FROM {semaphore} WHERE (value = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => 11447990474d22d35a7f86c2.09295213 ) in lock_release_all() (line 247 of C:\rnd\proprietary\rnd.emr.ph\drupal-7.x-dev\includes\lock.inc).

Uncaught exception thrown in session handler.
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in _drupal_session_write() (line 204 of C:\rnd\proprietary\rnd.emr.ph\drupal-7.x-dev\includes\session.inc).

keichee’s picture

Logo Here
Error

The website encountered an unexpected error. Please try again later.
Error messagePDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT 1 AS expression FROM {cache_update} cache_update WHERE ( (cid = :db_condition_placeholder_0) ) FOR UPDATE; Array ( [:db_condition_placeholder_0] => update_project_data ) in _update_cache_set() (line 763 of C:\rnd\proprietary\rnd.emr.ph\drupal-7.x-dev\modules\update\update.module).
Uncaught exception thrown in shutdown function.
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: DELETE FROM {semaphore} WHERE (value = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => 18847400194d22d440b23367.75208826 ) in lock_release_all() (line 247 of C:\rnd\proprietary\rnd.emr.ph\drupal-7.x-dev\includes\lock.inc).

Uncaught exception thrown in session handler.
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in _drupal_session_write() (line 204 of C:\rnd\proprietary\rnd.emr.ph\drupal-7.x-dev\includes\session.inc).

univate’s picture

Category:bug» support
Priority:Critical» Normal

That error means you can't connect to mysql, see http://dev.mysql.com/doc/refman/5.0/en/gone-away.html

keichee’s picture

nope, i can go to the ?q=user and other parts but not the admin

keichee’s picture

Logo Here
Error

The website encountered an unexpected error. Please try again later.
Error messagePDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT b.* FROM {block} b WHERE (b.theme = :db_condition_placeholder_0) AND (b.status = :db_condition_placeholder_1) ORDER BY b.region ASC, b.weight ASC, b.module ASC; Array ( [:db_condition_placeholder_0] => bartik [:db_condition_placeholder_1] => 1 ) in _block_load_blocks() (line 708 of C:\rnd\proprietary\rnd.emr.ph\drupal-7.x-dev\modules\block\block.module).
Uncaught exception thrown in session handler.
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: UPDATE {users} SET access=:db_update_placeholder_0 WHERE (uid = :db_condition_placeholder_0) ; Array ( [:db_update_placeholder_0] => 1294130151 [:db_condition_placeholder_0] => 1 ) in _drupal_session_write() (line 214 of C:\rnd\proprietary\rnd.emr.ph\drupal-7.x-dev\includes\session.inc).

Damien Tournoud’s picture

It means that your MySQL server is configured with a ridiculously small timeout. See the page of the MySQL manual linked in #4 for solutions.

keichee’s picture

Category:support» bug
Priority:Normal» Critical

drupal must auto connect to mysql server if that timeout happen, i guess drupal wont autoconnect on the fly

tim.plunkett’s picture

Category:bug» support
Priority:Critical» Normal
Crell’s picture

Status:Active» Postponed (maintainer needs more info)

Drupal doesn't connect to MySQL until the first query is sent. A request almost never takes more than a second, and usually less than half a second. If your MySQL server is timing out in that amount of time it means MySQL is misconfigured.

Please verify that you have a reasonable wait_timeout. I suspect simply increasing that will solve the problem.

wouter99999’s picture

I got similar errors with a new installation on 64bit Windows 7. This has to do with maximum allowed packet size in MySQL. To solve, add in the [mysqld] section in my.ini: max_allowed_packet=100M and restart MySQL

madhavvyas’s picture

edeloa’s picture

+1 for the solution above.

keichee’s picture

Status:Postponed (maintainer needs more info)» Closed (fixed)

many thanks

keichee’s picture

Assigned:Unassigned» keichee
joe casey’s picture

#12 above worked for me.

WAMP on Windows 7 localhost. Site ran fine but devel module dpm() call blew up with the 'MySQL server has gone away' message.

#12 solved it, #13 didn't help in my case.

Julia_yl’s picture

#12 above worked for me too thanks lots

wildermuthn’s picture

muschpusch’s picture

maybe not related but the solution from #20 worked for me. I got sleeping mysql processes running forever (until max connections where reached). It was when visiting admin/config in D7.8

BassPlaya’s picture

I've done the same thing as wouter99999 instructed in #12 (in a my.cnf file, copied from my-medium.cnf file) does but I extended it to 256M. I'm running MAMP Free and I must say that one site still gives me the error message when I'm trying to add a content type and the other doesn't. No idea why the other doesn't. If anyone knows, please share.

BassPlaya’s picture

it really is the 256M that does the trick. If I set it to 100M it throws that nasty error.

majingas’s picture

#12 worked for me aswell. Wamp on wun 7 64.

phprf’s picture

#12 Worked great for me! Wamp on Win7 Pro 64bit. Many thanks and God bless!

freerider839’s picture

#12 and #13 worked for me. thanks

wwgrey’s picture

WAMP on Windows 7 localhost:
#12 removed the issue
Thanks !

shasha_s’s picture

hello,

on Acquia dev desktop, win7 I changed in my.cfn

max_allowed_packet=128M to 256M

but I still get this, when I want to add new content type.

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
and
Uncaught exception thrown in session handler.

PDOException: There is already an active transaction in _drupal_session_write() (line 206 of...

how can I solve it?

thank you.
S.

kappaluppa’s picture

Post #12 http://drupal.org/node/1014172#comment-4142046
says change my.ini

Look in mysql/bin. This worked for me so far...

Tamanda’s picture

I had a similar problem, turned out the comment (#12) by wouter99999 fixed it. Thanks wouter99999, you saved me from a world of pain!!

clashar’s picture

wouter99999, thank you! your solution from #12 helped me well.

latulipeblanche’s picture

When you're on Linux, don't look for my.ini but for my.cnf

sudo gvim /opt/lampp/etc/my.cnf
sudo /opt/lampp/lampp restart

ntx wouter99999 http://drupal.org/node/1014172#comment-4142046

mrgoodcheese’s picture

#12 fixed my issue. Thank you.

garypigott39’s picture

#12 fixed my issue, but it had to be in the [mysqld] section (edited via WAMP "my.ini" option)
Cheers for the post.

honucreative’s picture

Just highlighting this (#34) , make sure it's in the [mysqld] section, by default there is the same setting in the [mysqldump] section, can be confusing for some.

ahenfo’s picture

Version:7.x-dev» 7.14
Priority:Normal» Major
Status:Closed (fixed)» Active

I have tried all the solutions given above but I'm still getting the same error message(MESSAGE BELOW). I am running Zend Server CE with the my-huge.ini as the default my.ini. I need help because all my drupal projects are inaccessible.

Error
The website encountered an unexpected error. Please try again later.
Error messagePDOException: SQLSTATE[42000]: Syntax error or access violation: 1286 Unknown table engine 'InnoDB': SELECT expire, value FROM {semaphore} WHERE name = :name; Array ( [:name] => variable_init ) in lock_may_be_available() (line 167 of C:\Zend\Apache2\htdocs\academy.org\includes\lock.inc).

Uncaught exception thrown in shutdown function.
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1286 Unknown table engine 'InnoDB': DELETE FROM {semaphore} WHERE (value = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => 68667015250329455dbcd27.47278376 ) in lock_release_all() (line 269 of C:\Zend\Apache2\htdocs\academy.org\includes\lock.inc).

rogical’s picture

Version:7.14» 7.15

max_allowed_packet = 16M solved my problem

ahenfo’s picture

Status:Active» Closed (fixed)
Exlord’s picture

max_allowed_packet=100M fixed mine ... tanks ...

firewolf’s picture

#12 helped mee too. Thank you!

cluther’s picture

NOTE: I found this to be a very time consuming and frustrating problem to solve. I leave this post as search bait to help others with a similar issue.

On my Drupal 7 site I was experiencing WSOD when attempting to add/edit a menu item (/structure/menu/item//edit), content type (admin/structure/types/manage/) or feature (admin/structure/features/create). All the tips provided at http://drupal.org/node/158043 on dealing with WSOD were of no help. I increased my PHP memory and added error reporting statements to index.php (see http://drupal.org/node/158043), but still there was the White Screen of Death and a total lack of insightful messages in any of the error log files (watchdog, php, apache, sql).

Further experimenting, I tried simplifying my environment. After I turned off DEVEL and I was presented with a Fatal error: Exception thrown without a stack frame in Unknown on line 0 error when visiting the page. Not a fix, but much better than a blank screen.

I then found a tip at http://www.drupal4hu.com/node/222 which suggested the issue might be one of the following:

  1. There was an exception while handling an exception.
  2. There was an exception while running a destructor.
  3. There was an exception while closing the session.
  4. There was an exception while running a shutdown function.

I followed the writer's recommendation of wrapping my index.php within a try-catch block and saving the catch to an error log. My index.php file now looks like:

<?php
try{
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

/**
 * @file
 * The PHP page that serves all page requests on a Drupal installation.
 * ...
 */

/**
 * Root directory of Drupal installation.
 */
define('DRUPAL_ROOT', getcwd());

require_once
DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
menu_execute_active_handler();

} catch (
exception $e) {file_put_contents('/tmp/drupal_error.log', $e->getMessage() . ' file: ' . $e->getFile() . ' on line '. $e->getLine()); }
?>

NOTE: Less the ending ?>.

I visited the page again and noticed that the following error was written to my drupal_error.log file.
SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

Which then led me to this page and to posts 12 & 13. If you follow post 13's link you will find the following:

This is very critical error found in MySQL. This error originate when you are dealt with huge records. There are various unanswered forum you will found when you Google that problem. The reason behind this crash is packet size. By default, MySQL configuration max_allowed_packet is set it to 16M. This settings may introduce this exception in your website..

Solution:
To resolve that problem you needs to increase max_allowed_packet variable in MySQL. Add following line in my.ini (or my.cnf)
max_allowed_packet=100M

Save the file and restart MySQL service. Now onward you will never get that kind exception in your open source / website.

I'm using MAMP on MacOS. So I modified the MySQL's my.cnf file and upped the max_allowed_packet default from 1M to 100M. Saved and rebooted MAMP. Problem solved. Yeah!

Raffy Martinez’s picture

Updated to 7.16 and got the error. # 12 worked but instead of 100M i set it at max_allowed_packet = 10M.

Thanks.

ydahi’s picture

After moving my site to a vps I started seeing this error. The error was volatile and I could not reproduce manually - it was very sporadic.

I attempted to fix it by increasing the max_packet_size, however this didn't work.

I noticed some references to the theme registry in the error. My site utilizes Zen.

I went into the appearance admin section and turned off "Rebuild theme registry on every page. " in the theme settings.

This fixed the solution for me.

mrudolph’s picture

As with ydahi (#43), it was the Zen theme which caused the aforementioned error with SQL, this after I had updated to Zen 7.x-5.1. No more playing with Zen, I guess!

willisiw’s picture

Posted by wouter99999 on February 26, 2011 at 6:44pm
I got similar errors with a new installation on 64bit Windows 7. This has to do with maximum allowed packet size in MySQL. To solve, add in the [mysqld] section in my.ini: max_allowed_packet=100M and restart MySQL

Perfect! Fixed my error on WAMP. I thought it had to do with my install of Commerce as it happened right behind installing a Commerce Module.

shankarpmenon’s picture

#12 is not working for me,
i am using wamp my sql 5.5

i have two web site working locally. one is working fine but the other is not working when i click add content type or edit a content type. but other wise the site is working perfectly.

ticocr’s picture

it seemed that drupal needed more packages when reading from databases since limit was set to 1M for some reason it was the default since there was not config file.

the site was still working, since for normal use it doesn't take that much from the database, but when logged into the administration panel it did take a lot data from mysql, over 1M as it was set..... It was working with all the modules that I already installed but not all configured and up and running, since some of them were in the off mode... I just Enabled some features of some modules on the modules panel and started giving me that error, nothing displayed other than showing that error where said: "SERVER HAS GONE AWAY"...

my first reaction was::: FUCK!! as usual.. then i started thinking.. and my first though was to remove some modules from the modules folder, but then I figured that some modules are needed by other modules.. so that would take forever, ... then I realized that it was showing a server issue... so i thought it was apache.. then mysql, and i started looking for mysql config file and no file found.,.. then I started reading about it mysql website and it popped up

so i knew it was mysql-server configuration, then I saw a post in drupal that said it was the packages drupal was getting from mysql... so what need to be modify was:

max_allowed_packet=1M to 2 or more Megs in mysql's my.cnf file.

bisonbleu’s picture

Ran into the same problem. This post on StackOverflow fixed it for me.

Skip-locking was removed in MySQL 5.5. See here. Edit your my.cnf file and change "skip-locking" to "skip-external-locking".

My setup:
- MAMP 1.9.6.1 (PHP 5.3.5, mySQL 5.5.9)
- MAMP/conf/my.cnf
- Drupal 7.21

albertosouza’s picture

I'm using gnu/linux fedora and add the setting of max_allowed_packet like comment #12 in the file /etc/my.cnf did not work.
After some testing i could change the configuration max_allowed_packet using the /etc/my.cnf.d/server.cnf and now the error gone away from my pc

ashwin.shaharkar’s picture

#12 is working for me.

Thanks.

afoster’s picture

#12 worked for MAMP 2.1.1. on OSX 10.8

namjoosadr’s picture

hi
sorry for my english
i test it and solve my problem.
in mysql shell insert this command
mysql >> SET GLOBAL max_allowed_packet=32*1024*1024;
and then import database

my os is centos 5

zelot’s picture

thanks #12. Works just fine

famishedroad’s picture

#12 worked perfectly for me! Many thanks.

NineAllexis’s picture

#12 worked for me, too! Thanks alot!

maikelm’s picture

Thanks, that's the general solution

cwpates’s picture

Component:mysql database» ajax system

For what It's worth, last step in installing Drupal Commons, this worked for me. Thanks..

alifspb’s picture

Default Re: High load: mysql --log-error=/var/lib/mysql/...

Since you are using MySQL 5.0, please try the following values to replace your existing /etc/my.cnf file (which might not be accurate to use as MySQL had been restarted in less than 24 hours when mysqltuner.pl was run):

Code:

[mysqld]
innodb_buffer_pool_size=20M
key_buffer_size = 512M
max_allowed_packet=100M
max_connections=500
max_heap_table_size=24M
open_files_limit=5000
query_cache_size=8M
table_cache = 2200
thread_cache_size=4
tmp_table_size=40M
log-slow-queries=/var/lib/mysql/slow.log

After this, then create the slow query log using these commands:

Code:

cd /var/lib/mysql
touch slow.log
chmod 660 slow.log
chown mysql:mysql slow.log

After doing that, then restart MySQL:

Code:

/etc/init.d/mysql restart
this help me solve my problem thanks

sonekun’s picture

Issue summary:View changes

I was having a problem with this uncaught exception error and server has gone away message when I tried to edit an order in drupal commerce (on shared hosting). I went back to my local host and checked if it gave the same error. It gave a different error relating to drupal firebug module. I then turned off Drupal Firebug and Drupal for Firebug Preprocessor modules. The error went away. Hope this helps somebody.

lprancourt’s picture

#12 Seems to solve this issue, but my website is hosted and I don't have access to that specific file. It is really bugging me as I can't use my admin user at all, I'm stuck. Everything was working well and have been for the last 3 months, on a production server, than I had many spams and tried to put in antispam module, and boom, now my admin user gets the WSOD , but not restricted users.

The site is still available for most, but my admin is dead, I really need to fix this, but I don't know how to change that setting in a shared server environment.

Thank for any help you can provide!

MariskaTh’s picture

I'm having a similar problem while trying to install Drupal 7.

After installing 27 modules (of 28) I get the following message:

'An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: http://localhost/drupal/install.php?profile=standard&locale=en&id=1&op=do StatusText: Service unavailable (with message) ResponseText: PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT expire, value FROM {semaphore} WHERE name = :name; Array ( [:name] => menu_rebuild ) in lock_may_be_available() (line 167 of C:\wamp\www\drupal\includes\lock.inc).Uncaught exception thrown in shutdown function.PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: DELETE FROM {semaphore} WHERE (value = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => 802228002541876118e8773.14607894 ) in lock_release_all() (line 269 of C:\wamp\www\drupal\includes\lock.inc).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] => ZLNqcOjZv5_OY8Y_fNwE0Il6hHmlJCLVL9qK5XUBTIo [:db_condition_placeholder_1] => ) in _drupal_session_write() (line 209 of C:\wamp\www\drupal\includes\session.inc).'

I have raised the number of the max_allowed_packet to various high amounts.
I have installed WAMP anew.
I have raised other numbers in my my.ini.
Each time I delete Drupal, my databank and my history in Chrome.

I have tried a lot of things, but I do not manage to install Drupal correctly. What can I try next?

Thanks,
Mariska.

ximix’s picture

#12 worked for me, too!! Thanks alot!!

Eranga’s picture

#12 worked for me.. Thanks

Tharick’s picture

#12 works well :-)

somenathdey’s picture

#12 Worked for me. Thanks