Answers.Body: <p>Drop index <strong>civicrm_mailing_event_queue</strong> (table <strong>civicrm_mailing_event_queue</strong>) then re-create it.</p>
  
  <p>After doing this, run the following check:</p>
  
  <pre><code>check table civicrm_mailing_event_queue
  </code></pre>
  
  <p>You should get a message that table status is 'OK'.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-30T15:18:55.873Z
Answers.Text: Fixed! Wasn't quite as simple as dropping and re-adding though. Attempts to drop gave me "#1075 - Incorrect table definition; there can be only one auto column, and it must be defined as a key." But after monkeying with it for several minutes, I got phpMyAdmin to accept an edit of the primary key. At that point, no more corrupt table warnings, and full SMS function via Twilio extension was restored.
Answers.UserDisplayName: Prónay
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-28T06:29:07.537Z
Answers.LastActivityDate: 2019-04-28T06:29:07.537Z
Answers.UserDisplayName: Djordje Marjanovic
Body: <p>Twilio extension worked great for the past year, but fails now. Outgoing messages seem unable to reach the Twilio API, though CRON is working. I've tried different versions of PHP with no effect. I've disabled all plugins except Civi, also with no effect. No changes were made to our extension settings or to our Twilio account configuration.</p>
  
  <p>From the Jobs Log:</p>
  
  <blockquote>
    <p>Entity: Job Action: process_sms</p>
    
    <p>Summary</p>
    
    <p>Finished execution of Send Scheduled SMS with result: Failure, Error
    message: DB Error: unknown error</p>
    
    <p>Details</p>
    
    <p>Parameters parsed (and passed to API method): 
    a:1:{s:7:"version";i:3;}</p>
    
    <p>Full message:   Finished execution of Send Scheduled SMS with result:
    Failure, Error message: DB Error: unknown error</p>
  </blockquote>
  
  <p>That's a bit vague, so I installed a working log viewer extension. Seems we're getting one of these every minute when the CRON job executes and fails to connect with Twilio.</p>
  
  <pre><code> [info] $Fatal Error Details = Array (
      [callback] =&gt; Array
          (
              [0] =&gt; CRM_Core_Error
              [1] =&gt; exceptionHandler
          )
  
      [code] =&gt; -1
      [message] =&gt; DB Error: unknown error
      [mode] =&gt; 16
      [debug_info] =&gt; 
                      SELECT      civicrm_mailing_event_queue.id,
                                  civicrm_phone.phone as phone,
                                  civicrm_mailing_event_queue.contact_id,
                                  civicrm_mailing_event_queue.hash,
                                  NULL as email
                      FROM        civicrm_mailing_event_queue
                      INNER JOIN  civicrm_phone
                              ON  civicrm_mailing_event_queue.phone_id = civicrm_phone.id
                      INNER JOIN  civicrm_contact
                              ON  civicrm_contact.id = civicrm_phone.contact_id
                      LEFT JOIN   civicrm_mailing_event_delivered
                              ON  civicrm_mailing_event_queue.id = civicrm_mailing_event_delivered.event_queue_id
                      LEFT JOIN   civicrm_mailing_event_bounce
                              ON  civicrm_mailing_event_queue.id = civicrm_mailing_event_bounce.event_queue_id
                      WHERE       civicrm_mailing_event_queue.job_id = 807
                          AND     civicrm_mailing_event_delivered.id IS null
                          AND     civicrm_mailing_event_bounce.id IS null
                          AND    ( civicrm_contact.is_opt_out = 0
                          OR       civicrm_contact.do_not_sms = 0 ) [nativecode=1712 ** Index civicrm_mailing_event_queue is corrupted]
      [type] =&gt; DB_Error
      [user_info] =&gt; 
                      SELECT      civicrm_mailing_event_queue.id,
                                  civicrm_phone.phone as phone,
                                  civicrm_mailing_event_queue.contact_id,
                                  civicrm_mailing_event_queue.hash,
                                  NULL as email
                      FROM        civicrm_mailing_event_queue
                      INNER JOIN  civicrm_phone
                              ON  civicrm_mailing_event_queue.phone_id = civicrm_phone.id
                      INNER JOIN  civicrm_contact
                              ON  civicrm_contact.id = civicrm_phone.contact_id
                      LEFT JOIN   civicrm_mailing_event_delivered
                              ON  civicrm_mailing_event_queue.id = civicrm_mailing_event_delivered.event_queue_id
                      LEFT JOIN   civicrm_mailing_event_bounce
                              ON  civicrm_mailing_event_queue.id = civicrm_mailing_event_bounce.event_queue_id
                      WHERE       civicrm_mailing_event_queue.job_id = 807
                          AND     civicrm_mailing_event_delivered.id IS null
                          AND     civicrm_mailing_event_bounce.id IS null
                          AND    ( civicrm_contact.is_opt_out = 0
                          OR       civicrm_contact.do_not_sms = 0 ) [nativecode=1712 ** Index civicrm_mailing_event_queue is corrupted]
      [to_string] =&gt; [db_error: message="DB Error: unknown error" code=-1 mode=callback callback=CRM_Core_Error::exceptionHandler prefix="" info="
                      SELECT      civicrm_mailing_event_queue.id,
                                  civicrm_phone.phone as phone,
                                  civicrm_mailing_event_queue.contact_id,
                                  civicrm_mailing_event_queue.hash,
                                  NULL as email
                      FROM        civicrm_mailing_event_queue
                      INNER JOIN  civicrm_phone
                              ON  civicrm_mailing_event_queue.phone_id = civicrm_phone.id
                      INNER JOIN  civicrm_contact
                              ON  civicrm_contact.id = civicrm_phone.contact_id
                      LEFT JOIN   civicrm_mailing_event_delivered
                              ON  civicrm_mailing_event_queue.id = civicrm_mailing_event_delivered.event_queue_id
                      LEFT JOIN   civicrm_mailing_event_bounce
                              ON  civicrm_mailing_event_queue.id = civicrm_mailing_event_bounce.event_queue_id
                      WHERE       civicrm_mailing_event_queue.job_id = 807
                          AND     civicrm_mailing_event_delivered.id IS null
                          AND     civicrm_mailing_event_bounce.id IS null
                          AND    ( civicrm_contact.is_opt_out = 0
                          OR       civicrm_contact.do_not_sms = 0 ) [nativecode=1712 ** Index civicrm_mailing_event_queue is corrupted]"] )
  </code></pre>
  
  <p>And here is the corresponding backtrace:</p>
  
  <pre><code> [info] $backTrace = #0 /REDACTED-PLUGINS-PATH/civicrm/civicrm/CRM/Core/Error.php(948): CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 /REDACTED-PLUGINS-PATH/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(922): CRM_Core_Error::exceptionHandler(Object(DB_Error))
  #2 /REDACTED-PLUGINS-PATH/civicrm/civicrm/packages/DB.php(985): PEAR_Error-&gt;__construct("DB Error: unknown error", -1, 16, (Array:2), "\n                    SELECT      civicrm_mailing_event_queue.id,\n          ...")
  #3 /REDACTED-PLUGINS-PATH/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error-&gt;__construct(-1, 16, (Array:2), "\n                    SELECT      civicrm_mailing_event_queue.id,\n          ...")
  #4 /REDACTED-PLUGINS-PATH/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR-&gt;_raiseError(Object(DB_mysqli), NULL, -1, 16, (Array:2), "\n                    SELECT      civicrm_mailing_event_queue.id,\n          ...", "DB_Error", TRUE)
  #5 /REDACTED-PLUGINS-PATH/civicrm/civicrm/packages/DB/common.php(1907): PEAR-&gt;__call("raiseError", (Array:7))
  #6 /REDACTED-PLUGINS-PATH/civicrm/civicrm/packages/DB/mysqli.php(933): DB_common-&gt;raiseError(-1, NULL, NULL, "\n                    SELECT      civicrm_mailing_event_queue.id,\n          ...", "1712 ** Index civicrm_mailing_event_queue is corrupted")
  #7 /REDACTED-PLUGINS-PATH/civicrm/civicrm/packages/DB/mysqli.php(403): DB_mysqli-&gt;mysqliRaiseError()
  #8 /REDACTED-PLUGINS-PATH/civicrm/civicrm/packages/DB/common.php(1216): DB_mysqli-&gt;simpleQuery("\n                    SELECT      civicrm_mailing_event_queue.id,\n          ...")
  #9 /REDACTED-PLUGINS-PATH/civicrm/civicrm/packages/DB/DataObject.php(2415): DB_common-&gt;query("\n                    SELECT      civicrm_mailing_event_queue.id,\n          ...")
  #10 /REDACTED-PLUGINS-PATH/civicrm/civicrm/packages/DB/DataObject.php(1607): DB_DataObject-&gt;_query("\n                    SELECT      civicrm_mailing_event_queue.id,\n          ...")
  #11 /REDACTED-PLUGINS-PATH/civicrm/civicrm/CRM/Core/DAO.php(438): DB_DataObject-&gt;query("\n                    SELECT      civicrm_mailing_event_queue.id,\n          ...")
  #12 /REDACTED-PLUGINS-PATH/civicrm/civicrm/CRM/Mailing/BAO/MailingJob.php(1125): CRM_Core_DAO-&gt;query("\n                    SELECT      civicrm_mailing_event_queue.id,\n          ...")
  #13 /REDACTED-PLUGINS-PATH/civicrm/civicrm/CRM/Mailing/BAO/MailingJob.php(540): CRM_Mailing_BAO_MailingJob::findPendingTasks("807", "sms")
  #14 /REDACTED-PLUGINS-PATH/civicrm/civicrm/CRM/Mailing/BAO/MailingJob.php(199): CRM_Mailing_BAO_MailingJob-&gt;deliver(Object(org_civicrm_sms_twilio), NULL)
  #15 /REDACTED-PLUGINS-PATH/civicrm/civicrm/CRM/Mailing/BAO/Mailing.php(2843): CRM_Mailing_BAO_MailingJob::runJobs(NULL, "sms")
  #16 /REDACTED-PLUGINS-PATH/civicrm/civicrm/api/v3/Job.php(380): CRM_Mailing_BAO_Mailing::processQueue("sms")
  #17 /REDACTED-PLUGINS-PATH/civicrm/civicrm/Civi/API/Provider/MagicFunctionProvider.php(100): civicrm_api3_job_process_sms((Array:1))
  #18 /REDACTED-PLUGINS-PATH/civicrm/civicrm/Civi/API/Kernel.php(169): Civi\API\Provider\MagicFunctionProvider-&gt;invoke((Array:9))
  #19 /REDACTED-PLUGINS-PATH/civicrm/civicrm/Civi/API/Kernel.php(100): Civi\API\Kernel-&gt;runRequest((Array:9))
  #20 /REDACTED-PLUGINS-PATH/civicrm/civicrm/api/api.php(23): Civi\API\Kernel-&gt;runSafe("Job", "process_sms", (Array:1), NULL)
  #21 /REDACTED-PLUGINS-PATH/civicrm/civicrm/CRM/Core/JobManager.php(146): civicrm_api("Job", "process_sms", (Array:1))
  #22 /REDACTED-PLUGINS-PATH/civicrm/civicrm/CRM/Core/JobManager.php(79): CRM_Core_JobManager-&gt;executeJob(Object(CRM_Core_ScheduledJob))
  #23 /REDACTED-PLUGINS-PATH/civicrm/civicrm/bin/cron.php(42): CRM_Core_JobManager-&gt;execute()
  #24 {main}
  </code></pre>
  
  <p>PHP 7.1.22</p>
  
  <p>CiviCRM 5.12.4</p>
  
  <p>WordPress 5.1.1</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-04-27T20:31:33.267Z
Comments.Text: Did you spot the error `Index civicrm_mailing_event_queue is corrupted`. It looks like a MySQL problem.
Comments.UserDisplayName: Kainuk - CiviCooP
Tags: <sms><civisms><twilio>
Title: Twilio extension failure w/ DB Error: unknown error
ThreadText: # Twilio extension failure w/ DB Error: unknown error
  
  (Asked by: username_0 on 2019-04-27)
  
  Twilio extension worked great for the past year, but fails now. Outgoing messages seem unable to reach the Twilio API, though CRON is working. I've tried different versions of PHP with no effect. I've disabled all plugins except Civi, also with no effect. No changes were made to our extension settings or to our Twilio account configuration.
  From the Jobs Log:
  
  Entity: Job Action: process_sms
  Summary
  Finished execution of Send Scheduled SMS with result: Failure, Error
    message: DB Error: unknown error
  Details
  Parameters parsed (and passed to API method): 
    a:1:{s:7:"version";i:3;}
  Full message:   Finished execution of Send Scheduled SMS with result:
    Failure, Error message: DB Error: unknown error
  
  That's a bit vague, so I installed a working log viewer extension. Seems we're getting one of these every minute when the CRON job executes and fails to connect with Twilio.
   [info] $Fatal Error Details = Array (
      [callback] => Array
          (
              [0] => CRM_Core_Error
              [1] => exceptionHandler
          )
  
      [code] => -1
      [message] => DB Error: unknown error
      [mode] => 16
      [debug_info] => 
                      SELECT      civicrm_mailing_event_queue.id,
                                  civicrm_phone.phone as phone,
                                  civicrm_mailing_event_queue.contact_id,
                                  civicrm_mailing_event_queue.hash,
                                  NULL as email
                      FROM        civicrm_mailing_event_queue
                      INNER JOIN  civicrm_phone
                              ON  civicrm_mailing_event_queue.phone_id = civicrm_phone.id
                      INNER JOIN  civicrm_contact
                              ON  civicrm_contact.id = civicrm_phone.contact_id
                      LEFT JOIN   civicrm_mailing_event_delivered
                              ON  civicrm_mailing_event_queue.id = civicrm_mailing_event_delivered.event_queue_id
                      LEFT JOIN   civicrm_mailing_event_bounce
                              ON  civicrm_mailing_event_queue.id = civicrm_mailing_event_bounce.event_queue_id
                      WHERE       civicrm_mailing_event_queue.job_id = 807
                          AND     civicrm_mailing_event_delivered.id IS null
                          AND     civicrm_mailing_event_bounce.id IS null
                          AND    ( civicrm_contact.is_opt_out = 0
                          OR       civicrm_contact.do_not_sms = 0 ) [nativecode=1712 ** Index civicrm_mailing_event_queue is corrupted]
      [type] => DB_Error
      [user_info] => 
                      SELECT      civicrm_mailing_event_queue.id,
                                  civicrm_phone.phone as phone,
                                  civicrm_mailing_event_queue.contact_id,
                                  civicrm_mailing_event_queue.hash,
                                  NULL as email
                      FROM        civicrm_mailing_event_queue
                      INNER JOIN  civicrm_phone
                              ON  civicrm_mailing_event_queue.phone_id = civicrm_phone.id
                      INNER JOIN  civicrm_contact
                              ON  civicrm_contact.id = civicrm_phone.contact_id
                      LEFT JOIN   civicrm_mailing_event_delivered
                              ON  civicrm_mailing_event_queue.id = civicrm_mailing_event_delivered.event_queue_id
                      LEFT JOIN   civicrm_mailing_event_bounce
                              ON  civicrm_mailing_event_queue.id = civicrm_mailing_event_bounce.event_queue_id
                      WHERE       civicrm_mailing_event_queue.job_id = 807
                          AND     civicrm_mailing_event_delivered.id IS null
                          AND     civicrm_mailing_event_bounce.id IS null
                          AND    ( civicrm_contact.is_opt_out = 0
                          OR       civicrm_contact.do_not_sms = 0 ) [nativecode=1712 ** Index civicrm_mailing_event_queue is corrupted]
      [to_string] => [db_error: message="DB Error: unknown error" code=-1 mode=callback callback=CRM_Core_Error::exceptionHandler prefix="" info="
                      SELECT      civicrm_mailing_event_queue.id,
                                  civicrm_phone.phone as phone,
                                  civicrm_mailing_event_queue.contact_id,
                                  civicrm_mailing_event_queue.hash,
                                  NULL as email
                      FROM        civicrm_mailing_event_queue
                      INNER JOIN  civicrm_phone
                              ON  civicrm_mailing_event_queue.phone_id = civicrm_phone.id
                      INNER JOIN  civicrm_contact
                              ON  civicrm_contact.id = civicrm_phone.contact_id
                      LEFT JOIN   civicrm_mailing_event_delivered
                              ON  civicrm_mailing_event_queue.id = civicrm_mailing_event_delivered.event_queue_id
                      LEFT JOIN   civicrm_mailing_event_bounce
                              ON  civicrm_mailing_event_queue.id = civicrm_mailing_event_bounce.event_queue_id
                      WHERE       civicrm_mailing_event_queue.job_id = 807
                          AND     civicrm_mailing_event_delivered.id IS null
                          AND     civicrm_mailing_event_bounce.id IS null
                          AND    ( civicrm_contact.is_opt_out = 0
                          OR       civicrm_contact.do_not_sms = 0 ) [nativecode=1712 ** Index civicrm_mailing_event_queue is corrupted]"] )
  
  And here is the corresponding backtrace:
   [info] $backTrace = #0 /REDACTED-PLUGINS-PATH/civicrm/civicrm/CRM/Core/Error.php(948): CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 /REDACTED-PLUGINS-PATH/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(922): CRM_Core_Error::exceptionHandler(Object(DB_Error))
  #2 /REDACTED-PLUGINS-PATH/civicrm/civicrm/packages/DB.php(985): PEAR_Error->__construct("DB Error: unknown error", -1, 16, (Array:2), "\n                    SELECT      civicrm_mailing_event_queue.id,\n          ...")
  #3 /REDACTED-PLUGINS-PATH/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error->__construct(-1, 16, (Array:2), "\n                    SELECT      civicrm_mailing_event_queue.id,\n          ...")
  #4 /REDACTED-PLUGINS-PATH/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR->_raiseError(Object(DB_mysqli), NULL, -1, 16, (Array:2), "\n                    SELECT      civicrm_mailing_event_queue.id,\n          ...", "DB_Error", TRUE)
  #5 /REDACTED-PLUGINS-PATH/civicrm/civicrm/packages/DB/common.php(1907): PEAR->__call("raiseError", (Array:7))
  #6 /REDACTED-PLUGINS-PATH/civicrm/civicrm/packages/DB/mysqli.php(933): DB_common->raiseError(-1, NULL, NULL, "\n                    SELECT      civicrm_mailing_event_queue.id,\n          ...", "1712 ** Index civicrm_mailing_event_queue is corrupted")
  #7 /REDACTED-PLUGINS-PATH/civicrm/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliRaiseError()
  #8 /REDACTED-PLUGINS-PATH/civicrm/civicrm/packages/DB/common.php(1216): DB_mysqli->simpleQuery("\n                    SELECT      civicrm_mailing_event_queue.id,\n          ...")
  #9 /REDACTED-PLUGINS-PATH/civicrm/civicrm/packages/DB/DataObject.php(2415): DB_common->query("\n                    SELECT      civicrm_mailing_event_queue.id,\n          ...")
  #10 /REDACTED-PLUGINS-PATH/civicrm/civicrm/packages/DB/DataObject.php(1607): DB_DataObject->_query("\n                    SELECT      civicrm_mailing_event_queue.id,\n          ...")
  #11 /REDACTED-PLUGINS-PATH/civicrm/civicrm/CRM/Core/DAO.php(438): DB_DataObject->query("\n                    SELECT      civicrm_mailing_event_queue.id,\n          ...")
  #12 /REDACTED-PLUGINS-PATH/civicrm/civicrm/CRM/Mailing/BAO/MailingJob.php(1125): CRM_Core_DAO->query("\n                    SELECT      civicrm_mailing_event_queue.id,\n          ...")
  #13 /REDACTED-PLUGINS-PATH/civicrm/civicrm/CRM/Mailing/BAO/MailingJob.php(540): CRM_Mailing_BAO_MailingJob::findPendingTasks("807", "sms")
  #14 /REDACTED-PLUGINS-PATH/civicrm/civicrm/CRM/Mailing/BAO/MailingJob.php(199): CRM_Mailing_BAO_MailingJob->deliver(Object(org_civicrm_sms_twilio), NULL)
  #15 /REDACTED-PLUGINS-PATH/civicrm/civicrm/CRM/Mailing/BAO/Mailing.php(2843): CRM_Mailing_BAO_MailingJob::runJobs(NULL, "sms")
  #16 /REDACTED-PLUGINS-PATH/civicrm/civicrm/api/v3/Job.php(380): CRM_Mailing_BAO_Mailing::processQueue("sms")
  #17 /REDACTED-PLUGINS-PATH/civicrm/civicrm/Civi/API/Provider/MagicFunctionProvider.php(100): civicrm_api3_job_process_sms((Array:1))
  #18 /REDACTED-PLUGINS-PATH/civicrm/civicrm/Civi/API/Kernel.php(169): Civi\API\Provider\MagicFunctionProvider->invoke((Array:9))
  #19 /REDACTED-PLUGINS-PATH/civicrm/civicrm/Civi/API/Kernel.php(100): Civi\API\Kernel->runRequest((Array:9))
  #20 /REDACTED-PLUGINS-PATH/civicrm/civicrm/api/api.php(23): Civi\API\Kernel->runSafe("Job", "process_sms", (Array:1), NULL)
  #21 /REDACTED-PLUGINS-PATH/civicrm/civicrm/CRM/Core/JobManager.php(146): civicrm_api("Job", "process_sms", (Array:1))
  #22 /REDACTED-PLUGINS-PATH/civicrm/civicrm/CRM/Core/JobManager.php(79): CRM_Core_JobManager->executeJob(Object(CRM_Core_ScheduledJob))
  #23 /REDACTED-PLUGINS-PATH/civicrm/civicrm/bin/cron.php(42): CRM_Core_JobManager->execute()
  #24 {main}
  
  PHP 7.1.22
  CiviCRM 5.12.4
  WordPress 5.1.1
  
  **Tags:** sms, civisms, twilio
  
  > **Comments:**
  > **username_1**: Did you spot the error `Index civicrm_mailing_event_queue is corrupted`. It looks like a MySQL problem.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-04-28. Score: 1 | Accepted answer
  
  Drop index civicrm_mailing_event_queue (table civicrm_mailing_event_queue) then re-create it.
  After doing this, run the following check:
  check table civicrm_mailing_event_queue
  
  You should get a message that table status is 'OK'.
  
  > **Comments:**
  > **username_0**: Fixed! Wasn't quite as simple as dropping and re-adding though. Attempts to drop gave me "#1075 - Incorrect table definition; there can be only one auto column, and it must be defined as a key." But after monkeying with it for several minutes, I got phpMyAdmin to accept an edit of the primary key. At that point, no more corrupt table warnings, and full SMS function via Twilio extension was restored.  
  
  ---
  
  