CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • CiviMail Error: Lost connection to MySQL server during query
Pages: [1]

Author Topic: CiviMail Error: Lost connection to MySQL server during query  (Read 1795 times)

emilyf

  • Ask me questions
  • ****
  • Posts: 696
  • Karma: 54
  • CiviCRM version: 2.x - 4.x
  • CMS version: Drupal 5, 6, 7
CiviMail Error: Lost connection to MySQL server during query
February 02, 2009, 09:06:59 am
I am trying to send a CiviMail out and for a particular group that I try to send to I get an error. It is a smart group. The interesting thing is that I have another mailing list that is a smart group, and this one works fine. And if I add the contacts from the problematic smart group to a new group that isn't a smart group, it works. But if I create a new group that's a smart group, add everyone from the first smart group to the new group, then ALL the smart groups will give this error after trying to get to the second page of the CiviMail wizard. Even the smart group that is initially working fine. Here is the error:
Code: [Select]
backTrace

/var/www/html/sites/all/modules/civicrm/CRM/Core/Error.php, backtrace, 138
, handle,
/var/www/html/sites/all/modules/civicrm/packages/PEAR.php, call_user_func, 912
/var/www/html/sites/all/modules/civicrm/packages/DB.php, PEAR_Error, 969
/var/www/html/sites/all/modules/civicrm/packages/PEAR.php, DB_Error, 574
/var/www/html/sites/all/modules/civicrm/packages/DB/common.php, raiseError, 1903
/var/www/html/sites/all/modules/civicrm/packages/DB/mysql.php, raiseError, 898
/var/www/html/sites/all/modules/civicrm/packages/DB/mysql.php, mysqlRaiseError, 327
/var/www/html/sites/all/modules/civicrm/packages/DB/common.php, simpleQuery, 1216
/var/www/html/sites/all/modules/civicrm/packages/DB/DataObject.php, query, 2394
/var/www/html/sites/all/modules/civicrm/packages/DB/DataObject.php, _query, 1587
/var/www/html/sites/all/modules/civicrm/CRM/Core/DAO.php, query, 144
/var/www/html/sites/all/modules/civicrm/CRM/Mailing/BAO/Mailing.php, query, 310
/var/www/html/sites/all/modules/civicrm/CRM/Mailing/BAO/Mailing.php, getRecipients, 121
/var/www/html/sites/all/modules/civicrm/CRM/Mailing/Form/Group.php, getRecipientsCount, 269
/var/www/html/sites/all/modules/civicrm/CRM/Core/Form.php, postProcess, 247
/var/www/html/sites/all/modules/civicrm/CRM/Core/StateMachine.php, mainProcess, 166
/var/www/html/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Next.php, perform, 63
/var/www/html/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php, perform, 203
/var/www/html/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php, handle, 103
/var/www/html/sites/all/modules/civicrm/CRM/Core/Controller.php, handle, 232
/var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php, run, 197
/var/www/html/sites/all/modules/civicrm/drupal/civicrm.module, invoke, 315
, civicrm_invoke,
/var/www/html/includes/menu.inc, call_user_func_array, 348
/var/www/html/index.php, menu_execute_active_handler, 18


unrecoverable error
    Sorry. A non-recoverable error has occurred.

    DB Error: a515ac9c2796ca0e23adbe92c68fc9fc

    Database Error Code: Lost connection to MySQL server during query, 2013

    Return to home page.

Error Details:

Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => a515ac9c2796ca0e23adbe92c68fc9fc
    [message] => DB Error: a515ac9c2796ca0e23adbe92c68fc9fc
    [mode] => 16
    [debug_info] => INSERT IGNORE INTO  I_1 (email_id, contact_id)
                    SELECT DISTINCT     civicrm_email.id as email_id,
                                        contact_a.id as contact_id
                     FROM civicrm_contact contact_a LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_email.is_primary = 1)   LEFT JOIN civicrm_entity_tag `civicrm_entity_tag-16,6,56,20,19,57,4,32,47,52,8,30,46,45,41,42,43,33,58,1,10,24,53,49,55,48,50,14,59,15,23,9,11,39,12,5` ON ( `civicrm_entity_tag-16,6,56,20,19,57,4,32,47,52,8,30,46,45,41,42,43,33,58,1,10,24,53,49,55,48,50,14,59,15,23,9,11,39,12,5`.contact_id = contact_a.id ) 
                    LEFT JOIN           X_1
                            ON          contact_a.id = X_1.contact_id
                    WHERE           
                                        contact_a.do_not_email = 0
                        AND             contact_a.is_opt_out = 0
                        AND             contact_a.is_deceased = 0
                        AND             (civicrm_email.is_bulkmail = 1 OR civicrm_email.is_primary = 1)
                        AND             civicrm_email.on_hold = 0
                                         AND ( `civicrm_entity_tag-16,6,56,20,19,57,4,32,47,52,8,30,46,45,41,42,43,33,58,1,10,24,53,49,55,48,50,14,59,15,23,9,11,39,12,5`.tag_id IN (16,6,56,20,19,57,4,32,47,52,8,30,46,45,41,42,43,33,58,1,10,24,53,49,55,48,50,14,59,15,23,9,11,39,12,5) )
                        AND             contact_a.id NOT IN (
                                          SELECT contact_id FROM civicrm_group_contact
                                          WHERE civicrm_group_contact.group_id = 42 AND civicrm_group_contact.status = 'Removed')
                        AND             X_1.contact_id IS null
                    ORDER BY civicrm_email.is_bulkmail [nativecode=2013 ** Lost connection to MySQL server during query]
    [type] => DB_Error
    [user_info] => INSERT IGNORE INTO  I_1 (email_id, contact_id)
                    SELECT DISTINCT     civicrm_email.id as email_id,
                                        contact_a.id as contact_id
                     FROM civicrm_contact contact_a LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_email.is_primary = 1)   LEFT JOIN civicrm_entity_tag `civicrm_entity_tag-16,6,56,20,19,57,4,32,47,52,8,30,46,45,41,42,43,33,58,1,10,24,53,49,55,48,50,14,59,15,23,9,11,39,12,5` ON ( `civicrm_entity_tag-16,6,56,20,19,57,4,32,47,52,8,30,46,45,41,42,43,33,58,1,10,24,53,49,55,48,50,14,59,15,23,9,11,39,12,5`.contact_id = contact_a.id ) 
                    LEFT JOIN           X_1
                            ON          contact_a.id = X_1.contact_id
                    WHERE           
                                        contact_a.do_not_email = 0
                        AND             contact_a.is_opt_out = 0
                        AND             contact_a.is_deceased = 0
                        AND             (civicrm_email.is_bulkmail = 1 OR civicrm_email.is_primary = 1)
                        AND             civicrm_email.on_hold = 0
                                         AND ( `civicrm_entity_tag-16,6,56,20,19,57,4,32,47,52,8,30,46,45,41,42,43,33,58,1,10,24,53,49,55,48,50,14,59,15,23,9,11,39,12,5`.tag_id IN (16,6,56,20,19,57,4,32,47,52,8,30,46,45,41,42,43,33,58,1,10,24,53,49,55,48,50,14,59,15,23,9,11,39,12,5) )
                        AND             contact_a.id NOT IN (
                                          SELECT contact_id FROM civicrm_group_contact
                                          WHERE civicrm_group_contact.group_id = 42 AND civicrm_group_contact.status = 'Removed')
                        AND             X_1.contact_id IS null
                    ORDER BY civicrm_email.is_bulkmail [nativecode=2013 ** Lost connection to MySQL server during query]
    [to_string] => [db_error: message="DB Error: a515ac9c2796ca0e23adbe92c68fc9fc" code=0 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT IGNORE INTO  I_1 (email_id, contact_id)
                    SELECT DISTINCT     civicrm_email.id as email_id,
                                        contact_a.id as contact_id
                     FROM civicrm_contact contact_a LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_email.is_primary = 1)   LEFT JOIN civicrm_entity_tag `civicrm_entity_tag-16,6,56,20,19,57,4,32,47,52,8,30,46,45,41,42,43,33,58,1,10,24,53,49,55,48,50,14,59,15,23,9,11,39,12,5` ON ( `civicrm_entity_tag-16,6,56,20,19,57,4,32,47,52,8,30,46,45,41,42,43,33,58,1,10,24,53,49,55,48,50,14,59,15,23,9,11,39,12,5`.contact_id = contact_a.id ) 
                    LEFT JOIN           X_1
                            ON          contact_a.id = X_1.contact_id
                    WHERE           
                                        contact_a.do_not_email = 0
                        AND             contact_a.is_opt_out = 0
                        AND             contact_a.is_deceased = 0
                        AND             (civicrm_email.is_bulkmail = 1 OR civicrm_email.is_primary = 1)
                        AND             civicrm_email.on_hold = 0
                                         AND ( `civicrm_entity_tag-16,6,56,20,19,57,4,32,47,52,8,30,46,45,41,42,43,33,58,1,10,24,53,49,55,48,50,14,59,15,23,9,11,39,12,5`.tag_id IN (16,6,56,20,19,57,4,32,47,52,8,30,46,45,41,42,43,33,58,1,10,24,53,49,55,48,50,14,59,15,23,9,11,39,12,5) )
                        AND             contact_a.id NOT IN (
                                          SELECT contact_id FROM civicrm_group_contact
                                          WHERE civicrm_group_contact.group_id = 42 AND civicrm_group_contact.status = 'Removed')
                        AND             X_1.contact_id IS null
                    ORDER BY civicrm_email.is_bulkmail [nativecode=2013 ** Lost connection to MySQL server during query]"]
)
[/code]

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviMail Error: Lost connection to MySQL server during query
February 02, 2009, 09:37:58 am

what happens when u cut-n-paste the select part of the query into mysql. How long does it take to evaluate?

i suspect the query gets too complex and is getting killed / running out of time and hence the below behavior.

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

emilyf

  • Ask me questions
  • ****
  • Posts: 696
  • Karma: 54
  • CiviCRM version: 2.x - 4.x
  • CMS version: Drupal 5, 6, 7
Re: CiviMail Error: Lost connection to MySQL server during query
February 02, 2009, 09:44:23 am
Yes, sorry, I forgot to post about that. When I run this directly in mysql:
Code: [Select]
SELECT DISTINCT civicrm_email.id AS email_id, contact_a.id AS contact_id
FROM civicrm_contact contact_a
LEFT JOIN civicrm_email ON ( contact_a.id = civicrm_email.contact_id
AND civicrm_email.is_primary =1 )
LEFT JOIN civicrm_entity_tag `civicrm_entity_tag-16,6,56,20,19,57,4,32,47,52,8,30,46,45,41,42,43,33,58,1,10,24,53,49,55,48,50,14,59,15,23,9,11,39,12,5` ON ( `civicrm_entity_tag-16,6,56,20,19,57,4,32,47,52,8,30,46,45,41,42,43,33,58,1,10,24,53,49,55,48,50,14,59,15,23,9,11,39,12,5`.contact_id = contact_a.id )
LEFT JOIN X_1 ON contact_a.id = X_1.contact_id
WHERE contact_a.do_not_email =0
AND contact_a.is_opt_out =0
AND contact_a.is_deceased =0
AND (
civicrm_email.is_bulkmail =1
OR civicrm_email.is_primary =1
)
AND civicrm_email.on_hold =0
AND (
`civicrm_entity_tag-16,6,56,20,19,57,4,32,47,52,8,30,46,45,41,42,43,33,58,1,10,24,53,49,55,48,50,14,59,15,23,9,11,39,12,5`.tag_id
IN ( 16, 6, 56, 20, 19, 57, 4, 32, 47, 52, 8, 30, 46, 45, 41, 42, 43, 33, 58, 1, 10, 24, 53, 49, 55, 48, 50, 14, 59, 15, 23, 9, 11, 39, 12, 5 )
)
AND contact_a.id NOT
IN (

SELECT contact_id
FROM civicrm_group_contact
WHERE civicrm_group_contact.group_id =42
AND civicrm_group_contact.status = 'Removed'
)
AND X_1.contact_id IS NULL
ORDER BY civicrm_email.is_bulkmail
LIMIT 0 ,
I get this error:

Code: [Select]
#1146 - Table 'cctvcivicrm.X_1' doesn't exist

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviMail Error: Lost connection to MySQL server during query
February 02, 2009, 12:00:11 pm

1. if you have access to your mysql query log, you can try recreating all the sql statements that civimail runs through

2. If you dont have access, can you run the above query and eliminate the two references to X_1 in the query. Most likely that does not have a significant performance impact

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • CiviMail Error: Lost connection to MySQL server during query

This forum was archived on 2017-11-26.