Answers.Body: <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-12T06:12:01.487Z
Answers.Text: 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.
Answers.UserDisplayName: Hugh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-12T10:55:16.447Z
Answers.Text: 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).
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-11T11:58:00.320Z
Answers.LastActivityDate: 2020-07-11T11:58:00.320Z
Answers.UserDisplayName: Demerit
Answers.Body: <p>So @demerit gave me the clue here. Several <code>log_civicrm_xxx</code> tables were corrupted <strong>before</strong> the upgrade (i.e. in my existing database), and <code>log_civicrm_msg_template</code> had some kind of corruption that caused it to disconnect the entire DB when mySQL tried to access it - even just <code>CHECK TABLE</code> flaked out, let alone OPTIMIZE.</p>
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-13T04:09:22.863Z
Answers.LastActivityDate: 2020-07-13T04:09:22.863Z
Answers.UserDisplayName: Hugh
Body: <p>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 -&gt; 5.26.x. I attempted to see what happened if I just pushed through to 5.27 but that throws the same error.</p>
  <p>In the upgrade screen it helpfully tells me there was an &quot;unknown error&quot;. The logs indicate there is some kind of MySQL problem, possibly related (but maybe not) to <a href="https://github.com/civicrm/civicrm-core/pull/17227" rel="nofollow noreferrer">this change</a>.</p>
  <p>I also see <code>DB Error: unknown error</code> when attempting to enable extensions (I disable them when upgrading).</p>
  <p>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.</p>
  <p><strong>System</strong></p>
  <p>WordPress: <code>5.4.2</code><br />
  MySQL: <code>Ver 14.14 Distrib 5.7.30 for Linux</code><br />
  OS: <code>Ubuntu Linux 18.04</code></p>
  <p>Error log shows:</p>
  <pre><code>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] =&gt; Array
          (
              [0] =&gt; CRM_Core_Error
              [1] =&gt; handle
          )
  
      [code] =&gt; -1
      [message] =&gt; DB Error: unknown error
      [mode] =&gt; 16
      [debug_info] =&gt; 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] =&gt; DB_Error
      [user_info] =&gt; 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] =&gt; [db_error: message=&quot;DB Error: unknown error&quot; code=-1 mode=callback callback=CRM_Core_Error::handle prefix=&quot;&quot; info=&quot;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]&quot;]
  )
  
  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(&quot;backTrace&quot;, 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-&gt;__construct(&quot;DB Error: unknown error&quot;, -1, 16, (Array:2), &quot;ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...&quot;)
  #3 /var/www/html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error-&gt;__construct(-1, 16, (Array:2), &quot;ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...&quot;)
  #4 /var/www/html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR-&gt;_raiseError(Object(DB_mysqli), NULL, -1, 16, (Array:2), &quot;ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...&quot;, &quot;DB_Error&quot;, TRUE)
  #5 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1925): PEAR-&gt;__call(&quot;raiseError&quot;, (Array:7))
  #6 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(935): DB_common-&gt;raiseError(-1, NULL, NULL, &quot;ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...&quot;, &quot;2006 ** MySQL server has gone away&quot;)
  #7 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(405): DB_mysqli-&gt;mysqliRaiseError()
  #8 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1231): DB_mysqli-&gt;simpleQuery(&quot;ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...&quot;)
  #9 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(2696): DB_common-&gt;query(&quot;ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...&quot;)
  #10 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(1829): DB_DataObject-&gt;_query(&quot;ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...&quot;)
  #11 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(421): DB_DataObject-&gt;query(&quot;ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...&quot;)
  #12 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(1473): CRM_Core_DAO-&gt;query(&quot;ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...&quot;, FALSE)
  #13 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Logging/Schema.php(450): CRM_Core_DAO::executeQuery(&quot;ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...&quot;, (Array:0), TRUE, NULL, FALSE, FALSE)
  #14 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Logging/Schema.php(529): CRM_Logging_Schema-&gt;fixSchemaDifferencesFor(&quot;civicrm_msg_template&quot;, (Array:3))
  #15 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Logging/Schema.php(284): CRM_Logging_Schema-&gt;fixSchemaDifferencesForAll()
  #16 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Upgrade/Form.php(790): CRM_Logging_Schema-&gt;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-&gt;runFinish()
  #19 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(312): CRM_Upgrade_Page_Upgrade-&gt;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-&gt;invoke(&quot;&quot;)
  #24 /var/www/html/wp-includes/class-wp-hook.php(311): WP_Hook-&gt;apply_filters(&quot;&quot;, (Array:1))
  #25 /var/www/html/wp-includes/plugin.php(478): WP_Hook-&gt;do_action((Array:1))
  #26 /var/www/html/wp-admin/admin.php(254): do_action(&quot;toplevel_page_CiviCRM&quot;)
  #27 {main}
  </code></pre>
  <p>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:</p>
  <pre><code>Jul 12 15:57:46  [error] $Fatal Error Details = Array
  (
      [callback] =&gt; Array
          (
              [0] =&gt; CRM_Core_Error
              [1] =&gt; handle
          )
  
      [code] =&gt; -14
      [message] =&gt; DB Error: no database selected
      [mode] =&gt; 16
      [debug_info] =&gt; SELECT VERSION() [nativecode=2006 ** MySQL server has gone away]
      [type] =&gt; DB_Error
      [user_info] =&gt; SELECT VERSION() [nativecode=2006 ** MySQL server has gone away]
      [to_string] =&gt; [db_error: message=&quot;DB Error: no database selected&quot; code=-14 mode=callback callback=CRM_Core_Error::handle prefix=&quot;&quot; info=&quot;SELECT VERSION() [nativecode=2006 ** MySQL server has gone away]&quot;]
  )
  
  
  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(&quot;backTrace&quot;, 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-&gt;__construct(&quot;DB Error: no database selected&quot;, -14, 16, (Array:2), &quot;SELECT VERSION() [nativecode=2006 ** MySQL server has gone away]&quot;)
  #3 /var/www/html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error-&gt;__construct(-14, 16, (Array:2), &quot;SELECT VERSION() [nativecode=2006 ** MySQL server has gone away]&quot;)
  #4 /var/www/html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR-&gt;_raiseError(Object(DB_mysqli), NULL, -14, 16, (Array:2), &quot;SELECT VERSION() [nativecode=2006 ** MySQL server has gone away]&quot;, &quot;DB_Error&quot;, TRUE)
  #5 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1925): PEAR-&gt;__call(&quot;raiseError&quot;, (Array:7))
  #6 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(935): DB_common-&gt;raiseError(-14, NULL, NULL, &quot;SELECT VERSION() [nativecode=2006 ** MySQL server has gone away]&quot;, &quot;2006 ** MySQL server has gone away&quot;)
  #7 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(390): DB_mysqli-&gt;mysqliRaiseError(-14)
  #8 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1231): DB_mysqli-&gt;simpleQuery(&quot;SELECT VERSION()&quot;)
  #9 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(2696): DB_common-&gt;query(&quot;SELECT VERSION()&quot;)
  #10 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(1829): DB_DataObject-&gt;_query(&quot;SELECT VERSION()&quot;)
  #11 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(421): DB_DataObject-&gt;query(&quot;SELECT VERSION()&quot;)
  #12 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(1550): CRM_Core_DAO-&gt;query(&quot;SELECT VERSION()&quot;, TRUE)
  #13 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Utils/SQL.php(168): CRM_Core_DAO::singleValueQuery(&quot;SELECT VERSION()&quot;)
  #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-&gt;acquire(NULL)
  #17 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Cache/SqlGroup.php(107): Civi\Core\Lock\LockManager-&gt;acquire(&quot;cache.CiviCRM-20Session__CRM_Admin_Form_Setting_Miscellaneous_74f5d2c2d697bc4...&quot;)
  #18 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/BAO/Cache.php(294): CRM_Utils_Cache_SqlGroup-&gt;set(&quot;_CRM_Admin_Form_Setting_Miscellaneous_74f5d2c2d697bc4ca6fb62aa04d3c992_241_co...&quot;, (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-&gt;__construct(&quot;DB Error: no database selected&quot;, -14, 16, (Array:2), &quot;ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...&quot;)
  #25 /var/www/html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error-&gt;__construct(-14, 16, (Array:2), &quot;ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...&quot;)
  #26 /var/www/html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR-&gt;_raiseError(Object(DB_mysqli), NULL, -14, 16, (Array:2), &quot;ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...&quot;, &quot;DB_Error&quot;, TRUE)
  #27 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1925): PEAR-&gt;__call(&quot;raiseError&quot;, (Array:7))
  #28 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(935): DB_common-&gt;raiseError(-14, NULL, NULL, &quot;ALTER TABLE `wordpress`.log_civicrm_msg_template ADD   `workflow_name` varcha...&quot;, &quot;2006 ** MySQL server has gone away&quot;)
  #29 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(618): DB_mysqli-&gt;mysqliRaiseError(-14)
  #30 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(2666): DB_mysqli-&gt;rollback()
  #31 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(1829): DB_DataObject-&gt;_query(&quot;ROLLBACK&quot;)
  #32 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(421): DB_DataObject-&gt;query(&quot;ROLLBACK&quot;)
  #33 /var/www/html/wp-content/plugins/civicrm/civicrm/Civi/Core/Transaction/Frame.php(153): CRM_Core_DAO-&gt;query(&quot;ROLLBACK&quot;)
  #34 /var/www/html/wp-content/plugins/civicrm/civicrm/Civi/Core/Transaction/Manager.php(103): Civi\Core\Transaction\Frame-&gt;finish()
  #35 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Transaction.php(127): Civi\Core\Transaction\Manager-&gt;dec()
  #36 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Transaction.php(114): CRM_Core_Transaction-&gt;commit()
  #37 /var/www/html/wp-content/plugins/civicrm/civicrm/Civi/API/Subscriber/TransactionSubscriber.php(169): CRM_Core_Transaction-&gt;__destruct()
  #38 /var/www/html/wp-content/plugins/civicrm/civicrm/vendor/symfony/event-dispatcher/EventDispatcher.php(184): Civi\API\Subscriber\TransactionSubscriber-&gt;onApiException(Object(Civi\API\Event\ExceptionEvent), &quot;civi.api.exception&quot;, Object(Civi\Core\CiviEventDispatcher))
  #39 /var/www/html/wp-content/plugins/civicrm/civicrm/vendor/symfony/event-dispatcher/EventDispatcher.php(46): Symfony\Component\EventDispatcher\EventDispatcher-&gt;doDispatch((Array:1), &quot;civi.api.exception&quot;, Object(Civi\API\Event\ExceptionEvent))
  #40 /var/www/html/wp-content/plugins/civicrm/civicrm/Civi/Core/CiviEventDispatcher.php(98): Symfony\Component\EventDispatcher\EventDispatcher-&gt;dispatch(&quot;civi.api.exception&quot;, Object(Civi\API\Event\ExceptionEvent))
  #41 /var/www/html/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(86): Civi\Core\CiviEventDispatcher-&gt;dispatch(&quot;civi.api.exception&quot;, Object(Civi\API\Event\ExceptionEvent))
  #42 /var/www/html/wp-content/plugins/civicrm/civicrm/api/api.php(131): Civi\API\Kernel-&gt;runSafe(&quot;setting&quot;, &quot;create&quot;, (Array:22))
  #43 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Admin/Form/SettingTrait.php(346): civicrm_api3(&quot;setting&quot;, &quot;create&quot;, (Array:22))
  #44 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Admin/Form/Setting.php(102): CRM_Admin_Form_Setting-&gt;saveMetadataDefinedSettings((Array:23))
  #45 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Admin/Form/Setting.php(82): CRM_Admin_Form_Setting-&gt;commonProcess((Array:23))
  #46 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php(484): CRM_Admin_Form_Setting-&gt;postProcess()
  #47 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/StateMachine.php(144): CRM_Core_Form-&gt;mainProcess()
  #48 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Next.php(45): CRM_Core_StateMachine-&gt;perform(Object(CRM_Admin_Form_Setting_Miscellaneous), &quot;next&quot;, &quot;Next&quot;)
  #49 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Next-&gt;perform(Object(CRM_Admin_Form_Setting_Miscellaneous), &quot;next&quot;)
  #50 /var/www/html/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller-&gt;handle(Object(CRM_Admin_Form_Setting_Miscellaneous), &quot;next&quot;)
  #51 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(335): HTML_QuickForm_Page-&gt;handle(&quot;next&quot;)
  #52 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Wrapper.php(98): CRM_Core_Controller-&gt;run()
  #53 /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(285): CRM_Utils_Wrapper-&gt;run(&quot;CRM_Admin_Form_Setting_Miscellaneous&quot;, &quot;Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.)&quot;, (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-&gt;invoke(&quot;&quot;)
  #58 /var/www/html/wp-includes/class-wp-hook.php(311): WP_Hook-&gt;apply_filters(&quot;&quot;, (Array:1))
  #59 /var/www/html/wp-includes/plugin.php(478): WP_Hook-&gt;do_action((Array:1))
  #60 /var/www/html/wp-admin/admin.php(254): do_action(&quot;toplevel_page_CiviCRM&quot;)
  #61 {main}
  </code></pre>
  
Tags: <wordpress><upgrade><error>
Title: "MySQL server has gone away" error when attempting upgrade to 5.26
ThreadText: # "MySQL server has gone away" error when attempting upgrade to 5.26
  
  (Asked by: username_0 on 2020-07-11)
  
  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}
  
  **Tags:** wordpress, upgrade, error
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-07-11. Score: 1 | Accepted answer
  
  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.
  
  > **Comments:**
  > **username_0**: Thanks @username_1 - 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.  
  > **username_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).  
  
  ---
  
  ### Answer by username_0 on 2020-07-13. Score: 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.
  
  
  ---
  
  