1
votes

Drupal 7

I am getting this error whenever I visit Configuration > Search and Metadata > URL aliases > Patterns (localhost/admin/config/search/path/patterns)

Original

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT 1 AS expression FROM {variable} variable WHERE ( (name = :db_condition_placeholder_0) ); Array ( [:db_condition_placeholder_0] => drupal_css_cache_files ) in variable_set() (line 991 of /home/www/icts-website/includes/bootstrap.inc).

Additional

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => php [:db_insert_placeholder_2] => %type: !message in %function (line %line of %file). [:db_insert_placeholder_3] => a:6:{s:5:"%type";s:12:"PDOException";s:8:"!message";s:235:"SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT 1 AS expression FROM {variable} variable WHERE ( (name = :db_condition_placeholder_0) ); Array ( [:db_condition_placeholder_0] => drupal_css_cache_files ) ";s:9:"%function";s:14:"variable_set()";s:5:"%file";s:45:"/home/www/icts-website/includes/bootstrap.inc";s:5:"%line";i:991;s:14:"severity_level";i:3;} [:db_insert_placeholder_4] => 3 [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => http://localhost/admin/config/search/path/patterns [:db_insert_placeholder_7] => http://localhost/ [:db_insert_placeholder_8] => 10.0.8.14 [:db_insert_placeholder_9] => 1444714070 ) in dblog_watchdog() (line 160 of /home/www/icts-website/modules/dblog/dblog.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] => 399784779561c9655b48719.42544548 ) in lock_release_all() (line 269 of /home/www/icts-website/includes/lock.inc).

I googled the solution and I also increased the max_allowed_packet to 32M but still the error page persist.

I will really appreciate your help in resolving this issue.

my.cnf file details is given below:

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

# include all files from the config directory
!includedir /etc/my.cnf.d

max_allowed_packet = 32M

I am using CentOS 7 and MySQL.

2
This usually indicates a lack of resources available to mySQL. The max_allowed_packet_size is only one variable. Could you post your my.cnf file (with any sensitive info removed) so we can see what's up?Quint
Thank you for answering the question. I have included the my.cnf file in question description.Mayank Sharma

2 Answers

4
votes

Yes, this error is related to parsing of large amount of data, so database fails as it can't handle such sizes due the given limits, therefore the server timing out and closing the connection.

To fix it, you need to increase further up the value of max_allowed_packet in your my.cnf (e.g. ~/.my.cnf) under [mysqld] section, e.g.

[mysqld]
max_allowed_packet=256M

Try with 256M, if won't help, try increasing further more (e.g. 1G).

In your case, I think max_allowed_packet should be under [mysqld] section specifically, not under [mysqld_safe], so settings are applied to the right component.

See: B.5.2.9 MySQL server has gone away for more detailed information.

Another thing is that in this particular case it happens in shutdown function (which is after Drupal finished the processing of the site), therefore it could be related to some cron or debugging tasks.

1
votes

It looks like your my.cnf is missing some entries for InnoDB that might help

innodb_buffer_pool_size = 256M
innodb_additional_mem_pool_size = 10M
innodb_lock_wait_timeout = 180

I have these additional lines in my MySQL config. It may or may not be the solution for you, but it is definitely worth a try. Let me know if this doesn't help. You may need to tweak these values a bit depending on your environment.

-- Don't forget to restart MySQL after making changes to my.cnf.