1

I get the following error in various situations, detailed below.

SQLSTATE[HY000]: General error: 2006 MySQL server has gone away DB Error: unknown error

I get it consistently when trying to enter the duplicate merging dialog; and I've gotten it occasionally when importing data, deleting events (without participants), and other routine tasks. It displays the message twice when the error happens (three times if watchdog is on). It's happening on multiple CiviCRM sites on the same server.

The Googled consensus seems to be to increase max_allowed_packet in my.cnf but this hasn't helped in my case (it was 24M and is now at 64M). Restarting mySQL and the server itself have also not resolved the issue. Any suggestion is welcome.

Backtrace when trying to enter the duplicate merging dialog:

0 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/CRM/Core/Error.php(182): CRM_Core_Error::backtrace()

1 internal function: CRM_Core_Error::handle(Object(DB_Error))

2 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))

3 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/packages/DB.php(976): PEAR_Error->PEAR_Error("DB Error: unknown error", -1, 16, (Array:2), "\nSELECT\n table_name,\n column_name\nFROM information_schema.key_colum...")

4 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/packages/PEAR.php(564): DB_Error->DB_Error(-1, 16, (Array:2), "\nSELECT\n table_name,\n column_name\nFROM information_schema.key_colum...")

5 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -1, NULL, NULL, "\nSELECT\n table_name,\n column_name\nFROM information_schema.key_colum...", "DB_Error", TRUE)

6 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/packages/DB/mysql.php(895): DB_common->raiseError(-1, NULL, NULL, NULL, "2006 ** MySQL server has gone away")

7 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/packages/DB/mysql.php(328): DB_mysql->mysqlRaiseError()

8 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/packages/DB/common.php(1216): DB_mysql->simpleQuery("\nSELECT\n table_name,\n column_name\nFROM information_schema.key_colum...")

9 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/packages/DB/DataObject.php(2442): DB_common->query("\nSELECT\n table_name,\n column_name\nFROM information_schema.key_colum...")

10 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/packages/DB/DataObject.php(1634): DB_DataObject->_query("\nSELECT\n table_name,\n column_name\nFROM information_schema.key_colum...")

11 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/CRM/Core/DAO.php(325): DB_DataObject->query("\nSELECT\n table_name,\n column_name\nFROM information_schema.key_colum...")

12 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/CRM/Core/DAO.php(1192): CRM_Core_DAO->query("\nSELECT\n table_name,\n column_name\nFROM information_schema.key_colum...", TRUE)

13 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/CRM/Dedupe/Merger.php(207): CRM_Core_DAO::executeQuery("\nSELECT\n table_name,\n column_name\nFROM information_schema.key_colum...")

14 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/CRM/Dedupe/Merger.php(166): CRM_Dedupe_Merger::cidRefs()

15 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/CRM/Dedupe/Merger.php(1102): CRM_Dedupe_Merger::getActiveRelTables("19986")

16 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/CRM/Contact/Form/Merge.php(193): CRM_Dedupe_Merger::getRowsElementsAndInfo("19985", "19986")

17 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/CRM/Core/Form.php(455): CRM_Contact_Form_Merge->preProcess()

18 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Display.php(94): CRM_Core_Form->buildForm()

19 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Display->perform(Object(CRM_Contact_Form_Merge), "display")

20 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Contact_Form_Merge), "display")

21 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/CRM/Core/Controller.php(353): HTML_QuickForm_Page->handle("display")

22 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/CRM/Utils/Wrapper.php(115): CRM_Core_Controller->run()

23 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/CRM/Core/Invoke.php(286): CRM_Utils_Wrapper->run("CRM_Contact_Form_Merge", "Merge Contact", NULL)

24 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/CRM/Core/Invoke.php(86): CRM_Core_Invoke::runItem((Array:13))

25 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/CRM/Core/Invoke.php(54): CRM_Core_Invoke::_invoke((Array:3))

26 /home/domainname/public_html/subdomainname/sites/all/modules/civicrm/drupal/civicrm.module(489): CRM_Core_Invoke::invoke((Array:3))

27 internal function: civicrm_invoke("contact", "merge")

28 /home/domainname/public_html/subdomainname/includes/menu.inc(519): call_user_func_array("civicrm_invoke", (Array:2))

29 /home/domainname/public_html/subdomainname/index.php(21): menu_execute_active_handler()

30 {main}

  • try removing max_allowed_packet line from my.cnf file so the server will pick up default value (unlimited) - – Ramesh - ARTECH Consultancy Mar 2 '16 at 16:51
  • Thank you, but there's no change after applying that setting (and restarting mysql). – Eric H Mar 2 '16 at 21:13
  • To add a dimension to this, it's happening in mySQL 5.6 and I'm considering an upgrade to MariaDB 10 as a possible solution since mySQL has given me many headaches. – Eric H Mar 2 '16 at 22:38
2

After a long back and forth with support, we narrowed it down to corrupted CiviCRM tables. The corrupted tables weren't even in the same CiviCRM database that was having trouble, and they were causing phpMyAdmin to lose the DB connection in certain cases. Here's the process I used to fix things:

  1. Set your site to offline
  2. Go to a command line (I used Putty).
  3. Enter mysqlcheck databasename_civicrm to get a status report on all tables.
  4. The process may halt with an error message (or if no error message it'll tell you which are/aren't corrupted). In my case, when it halted, I assumed that the first unlisted table (alphabetically) was the problem table and dropped it (Important: Dropping means you're deleting it. It's a big deal. You'll want to have a backup ready and think about the implications for related tables).
  5. Drop the offending table(s). I used phpMyAdmin for this.
  6. Restore the offending table(s) from a viable backup.
  7. Enter mysqlcheck databasename_civicrm again to get a status report on all tables. Repeat the drop/restore process if necessary.
  8. Assuming you're in the clear, put your site back online.

After I did this, all the processes that formerly gave the error no longer did so I consider it fixed.

1

This is an extremely generic error, which basically means "MySQL froze up", and you'll need to check your MySQL and system logs rather than/in addition to CiviCRM for answers. Check your server's system logs to see if perhaps oom-killer decided to kill MySQL because you're out of memory.

  • 1
    You're correct. The error runs deeper than how CiviCRM is using mySQL, and is a basic mySQL problem. It's reported by an older mysqltuner, but not the new one oddly. I'm working with my hosting support and will post the solution. – Eric H Mar 4 '16 at 22:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.