1

I am attempting to upgrade from 5.24 to 5.27 by stepping through 5.25 and 5.26, however I'm getting weird errors at 5.25.0 -> 5.26.x. I attempted to see what happened if I just pushed through to 5.27 but that throws the same error.

In the upgrade screen it helpfully tells me there was an "unknown error". The logs indicate there is some kind of MySQL problem, possibly related (but maybe not) to this change.

I also see DB Error: unknown error when attempting to enable extensions (I disable them when upgrading).

I've rolled back for now but this is going to become urgent the closer we get to the new WordPress version on 11 August so any suggestions would be greatly appreciated.

System

WordPress: 5.4.2
MySQL: Ver 14.14 Distrib 5.7.30 for Linux
OS: Ubuntu Linux 18.04

Error log shows:

Jul 11 15:41:57  [info] Running task: Finish Upgrade DB to 5.26.0

Jul 11 15:42:07  [error] $Fatal Error Details = Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -1
    [message] => DB Error: unknown error
    [mode] => 16
    [debug_info] => ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Name of workflow' [nativecode=2006 ** MySQL server has gone away]
    [type] => DB_Error
    [user_info] => ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Name of workflow' [nativecode=2006 ** MySQL server has gone away]
    [to_string] => [db_error: message="DB Error: unknown error" code=-1 mode=callback callback=CRM_Core_Error::handle prefix="" info="ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Name of workflow' [nativecode=2006 ** MySQL server has gone away]"]
)

Jul 11 15:42:07  [debug] $backTrace = #0 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(192): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 /var/www/html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(922): CRM_Core_Error::handle(Object(DB_Error))
#2 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB.php(997): PEAR_Error->__construct("DB Error: unknown error", -1, 16, (Array:2), "ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...")
#3 /var/www/html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error->__construct(-1, 16, (Array:2), "ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...")
#4 /var/www/html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR->_raiseError(Object(DB_mysqli), NULL, -1, 16, (Array:2), "ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...", "DB_Error", TRUE)
#5 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1925): PEAR->__call("raiseError", (Array:7))
#6 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(935): DB_common->raiseError(-1, NULL, NULL, "ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...", "2006 ** MySQL server has gone away")
#7 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(405): DB_mysqli->mysqliRaiseError()
#8 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1231): DB_mysqli->simpleQuery("ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...")
#9 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(2696): DB_common->query("ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...")
#10 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(1829): DB_DataObject->_query("ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...")
#11 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(421): DB_DataObject->query("ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...")
#12 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(1473): CRM_Core_DAO->query("ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...", FALSE)
#13 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Logging/Schema.php(450): CRM_Core_DAO::executeQuery("ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...", (Array:0), TRUE, NULL, FALSE, FALSE)
#14 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Logging/Schema.php(529): CRM_Logging_Schema->fixSchemaDifferencesFor("civicrm_msg_template", (Array:3))
#15 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Logging/Schema.php(284): CRM_Logging_Schema->fixSchemaDifferencesForAll()
#16 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Upgrade/Form.php(790): CRM_Logging_Schema->fixSchemaDifferences()
#17 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Upgrade/Page/Upgrade.php(165): CRM_Upgrade_Form::doFinish()
#18 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Upgrade/Page/Upgrade.php(65): CRM_Upgrade_Page_Upgrade->runFinish()
#19 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(312): CRM_Upgrade_Page_Upgrade->run((Array:2), NULL)
#20 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(68): CRM_Core_Invoke::runItem((Array:13))
#21 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke((Array:2))
#22 /var/www/html/wp-content/plugins/civicrm/civicrm.php(1535): CRM_Core_Invoke::invoke((Array:2))
#23 /var/www/html/wp-includes/class-wp-hook.php(287): CiviCRM_For_WordPress->invoke("")
#24 /var/www/html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters("", (Array:1))
#25 /var/www/html/wp-includes/plugin.php(478): WP_Hook->do_action((Array:1))
#26 /var/www/html/wp-admin/admin.php(254): do_action("toplevel_page_CiviCRM")
#27 {main}

If I turn off logging, that looks like it fixes the problem. However that's not actually true, because when I go to turn it back on I get a similar error:

Jul 12 15:57:46  [error] $Fatal Error Details = Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -14
    [message] => DB Error: no database selected
    [mode] => 16
    [debug_info] => SELECT VERSION() [nativecode=2006 ** MySQL server has gone away]
    [type] => DB_Error
    [user_info] => SELECT VERSION() [nativecode=2006 ** MySQL server has gone away]
    [to_string] => [db_error: message="DB Error: no database selected" code=-14 mode=callback callback=CRM_Core_Error::handle prefix="" info="SELECT VERSION() [nativecode=2006 ** MySQL server has gone away]"]
)


Jul 12 15:57:46  [debug] $backTrace = #0 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(192): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 /var/www/html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(922): CRM_Core_Error::handle(Object(DB_Error))
#2 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB.php(997): PEAR_Error->__construct("DB Error: no database selected", -14, 16, (Array:2), "SELECT VERSION() [nativecode=2006 ** MySQL server has gone away]")
#3 /var/www/html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error->__construct(-14, 16, (Array:2), "SELECT VERSION() [nativecode=2006 ** MySQL server has gone away]")
#4 /var/www/html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR->_raiseError(Object(DB_mysqli), NULL, -14, 16, (Array:2), "SELECT VERSION() [nativecode=2006 ** MySQL server has gone away]", "DB_Error", TRUE)
#5 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1925): PEAR->__call("raiseError", (Array:7))
#6 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(935): DB_common->raiseError(-14, NULL, NULL, "SELECT VERSION() [nativecode=2006 ** MySQL server has gone away]", "2006 ** MySQL server has gone away")
#7 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(390): DB_mysqli->mysqliRaiseError(-14)
#8 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1231): DB_mysqli->simpleQuery("SELECT VERSION()")
#9 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(2696): DB_common->query("SELECT VERSION()")
#10 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(1829): DB_DataObject->_query("SELECT VERSION()")
#11 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(421): DB_DataObject->query("SELECT VERSION()")
#12 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(1550): CRM_Core_DAO->query("SELECT VERSION()", TRUE)
#13 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Utils/SQL.php(168): CRM_Core_DAO::singleValueQuery("SELECT VERSION()")
#14 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Utils/SQL.php(150): CRM_Utils_SQL::getDatabaseVersion()
#15 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Lock.php(169): CRM_Utils_SQL::supportsMultipleLocks()
#16 /var/www/html/wp-content/plugins/civicrm/civicrm/Civi/Core/Lock/LockManager.php(68): CRM_Core_Lock->acquire(NULL)
#17 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Cache/SqlGroup.php(107): Civi\Core\Lock\LockManager->acquire("cache.CiviCRM-20Session__CRM_Admin_Form_Setting_Miscellaneous_74f5d2c2d697bc4...")
#18 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/BAO/Cache.php(294): CRM_Utils_Cache_SqlGroup->set("_CRM_Admin_Form_Setting_Miscellaneous_74f5d2c2d697bc4ca6fb62aa04d3c992_241_co...", (Array:5), 172800)
#19 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Session.php(517): CRM_Core_BAO_Cache::storeSessionToCache((Array:2), TRUE)
#20 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Utils/System.php(1428): CRM_Core_Session::storeSessionObjects()
#21 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(981): CRM_Utils_System::civiExit(1)
#22 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(207): CRM_Core_Error::abend(1)
#23 /var/www/html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(922): CRM_Core_Error::handle(Object(DB_Error))
#24 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB.php(997): PEAR_Error->__construct("DB Error: no database selected", -14, 16, (Array:2), "ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...")
#25 /var/www/html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error->__construct(-14, 16, (Array:2), "ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...")
#26 /var/www/html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR->_raiseError(Object(DB_mysqli), NULL, -14, 16, (Array:2), "ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...", "DB_Error", TRUE)
#27 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1925): PEAR->__call("raiseError", (Array:7))
#28 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(935): DB_common->raiseError(-14, NULL, NULL, "ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...", "2006 ** MySQL server has gone away")
#29 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(618): DB_mysqli->mysqliRaiseError(-14)
#30 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(2666): DB_mysqli->rollback()
#31 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(1829): DB_DataObject->_query("ROLLBACK")
#32 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(421): DB_DataObject->query("ROLLBACK")
#33 /var/www/html/wp-content/plugins/civicrm/civicrm/Civi/Core/Transaction/Frame.php(153): CRM_Core_DAO->query("ROLLBACK")
#34 /var/www/html/wp-content/plugins/civicrm/civicrm/Civi/Core/Transaction/Manager.php(103): Civi\Core\Transaction\Frame->finish()
#35 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Transaction.php(127): Civi\Core\Transaction\Manager->dec()
#36 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Transaction.php(114): CRM_Core_Transaction->commit()
#37 /var/www/html/wp-content/plugins/civicrm/civicrm/Civi/API/Subscriber/TransactionSubscriber.php(169): CRM_Core_Transaction->__destruct()
#38 /var/www/html/wp-content/plugins/civicrm/civicrm/vendor/symfony/event-dispatcher/EventDispatcher.php(184): Civi\API\Subscriber\TransactionSubscriber->onApiException(Object(Civi\API\Event\ExceptionEvent), "civi.api.exception", Object(Civi\Core\CiviEventDispatcher))
#39 /var/www/html/wp-content/plugins/civicrm/civicrm/vendor/symfony/event-dispatcher/EventDispatcher.php(46): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch((Array:1), "civi.api.exception", Object(Civi\API\Event\ExceptionEvent))
#40 /var/www/html/wp-content/plugins/civicrm/civicrm/Civi/Core/CiviEventDispatcher.php(98): Symfony\Component\EventDispatcher\EventDispatcher->dispatch("civi.api.exception", Object(Civi\API\Event\ExceptionEvent))
#41 /var/www/html/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(86): Civi\Core\CiviEventDispatcher->dispatch("civi.api.exception", Object(Civi\API\Event\ExceptionEvent))
#42 /var/www/html/wp-content/plugins/civicrm/civicrm/api/api.php(131): Civi\API\Kernel->runSafe("setting", "create", (Array:22))
#43 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Admin/Form/SettingTrait.php(346): civicrm_api3("setting", "create", (Array:22))
#44 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Admin/Form/Setting.php(102): CRM_Admin_Form_Setting->saveMetadataDefinedSettings((Array:23))
#45 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Admin/Form/Setting.php(82): CRM_Admin_Form_Setting->commonProcess((Array:23))
#46 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php(484): CRM_Admin_Form_Setting->postProcess()
#47 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/StateMachine.php(144): CRM_Core_Form->mainProcess()
#48 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Next.php(45): CRM_Core_StateMachine->perform(Object(CRM_Admin_Form_Setting_Miscellaneous), "next", "Next")
#49 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Next->perform(Object(CRM_Admin_Form_Setting_Miscellaneous), "next")
#50 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Admin_Form_Setting_Miscellaneous), "next")
#51 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(335): HTML_QuickForm_Page->handle("next")
#52 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Wrapper.php(98): CRM_Core_Controller->run()
#53 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(285): CRM_Utils_Wrapper->run("CRM_Admin_Form_Setting_Miscellaneous", "Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.)", (Array:0))
#54 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(68): CRM_Core_Invoke::runItem((Array:16))
#55 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke((Array:4))
#56 /var/www/html/wp-content/plugins/civicrm/civicrm.php(1535): CRM_Core_Invoke::invoke((Array:4))
#57 /var/www/html/wp-includes/class-wp-hook.php(287): CiviCRM_For_WordPress->invoke("")
#58 /var/www/html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters("", (Array:1))
#59 /var/www/html/wp-includes/plugin.php(478): WP_Hook->do_action((Array:1))
#60 /var/www/html/wp-admin/admin.php(254): do_action("toplevel_page_CiviCRM")
#61 {main}

2 Answers 2

1

Try turning logging off (administer - system settings - misc) and then doing the upgrade and then turning logging back on again. It seems like the log table definitions/triggers are getting out of sync for some reason.

2
  • Thanks @Demerit - that looked like it had worked, in that the update finished. However after that I can't turn logging back on. I get essentially the same error, and the Stripe extension also has catastrophic failures so something clearly is badly wrong re my database somewhere. I've updated the question.
    – Hugh
    Jul 12, 2020 at 6:12
  • 1
    Could try OPTIMIZE TABLE log_civicrm_msg_template - if it's corrupt that might fix it. And/or is there anything in the log_civicrm_msg_template table you want to keep? Could try dropping that table and then turning logging off and then back on which should recreate it (can do a backup, or SHOW CREATE TABLE log_civicrm_msg_template and copying the output to clipboard before dropping which would allow recreating the structure without data at least manually).
    – Demerit
    Jul 12, 2020 at 10:55
1

So @demerit gave me the clue here. Several log_civicrm_xxx tables were corrupted before the upgrade (i.e. in my existing database), and log_civicrm_msg_template had some kind of corruption that caused it to disconnect the entire DB when mySQL tried to access it - even just CHECK TABLE flaked out, let alone OPTIMIZE.

Since I don't really care about the logging tables the simple fix was to drop the offending ones and turn off logging. I tested turning logging back on and then off again after upgrading and everything seems to be ok.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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