0

I'm at a similar situation as in this question, which was a bug that supposedly got fixed.

Scheduled mailings get started by the cron job, but no mailings are sent and the job never finish.

We had this at 4.7.17 and have just upgraded to 4.7.20 where it also exists.

The job log indicate no error, there is nothing in the logs. BUT SEE UPDATE!

Also running the job with "Run now" as the same user as the cron job sends and finishes the job. Running the same command as the cronjob (php bin/cli.php -j <site> -u <user> -p <passw> -e Job -a execute) from the servers command line does not send the mailings but the run is registered by the "Scheduled jobs" log.

The wgetmethod does not seem to work either, which indicates that it is not the same as the other issue.

UPDATE: There seems to be something related in the logs. It happens on the scheduling, so the timing is unrelated to the cronjobs, that's why I missed it.

It's a missing field error (which might be triggers or something else...). I've pasted the complete log at the end of the question. The relevant part is probably this:

[debug_info] =>
INSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )
SELECT ANY_VALUE(265), ANY_VALUE(i.contact_id), ANY_VALUE(i.phone_id)
FROM       civicrm_contact contact_a
INNER JOIN I_1253 i ON contact_a.id = i.contact_id
            INNER JOIN civicrm_email e ON e.id = i.email_id
           WHERE contact_a.is_deleted = 0
            GROUP BY e.email
ORDER BY   MIN(i.contact_id), MIN(i.phone_id)
 [nativecode=1054 ** Unknown column 'i.email_id' in 'on clause']

and this:

#9 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/mysqli.php(933): DB_common->raiseError(-19, NULL, NULL, NULL, "1054 ** Unknown column 'i.email_id' in 'on clause'")
#10 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliRaiseError()
#11 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/common.php(1216): DB_mysqli->simpleQuery("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
#12 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php(2446): DB_common->query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
#13 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php(1635): DB_DataObject->_query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
#14 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php(362): DB_DataObject->query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
#15 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php(1315): CRM_Core_DAO->query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...", TRUE)
#16 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Mailing/BAO/Mailing.php(565): CRM_Core_DAO::executeQuery("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...", (Array:1))
#17 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Mailing/BAO/Mailing.php(1791): CRM_Mailing_BAO_Mailing::getRecipients("1253", "265", TRUE, "1", "sms")
#18 [internal function](): CRM_Mailing_BAO_Mailing::create((Array:54))
#19 /var/www/events/administrator/components/com_civicrm/civicrm/api/v3/utils.php(1284): call_user_func_array((Array:2), (Array:1))
#20 /var/www/events/administrator/components/com_civicrm/civicrm/api/v3/Mailing.php(70): _civicrm_api3_basic_create("CRM_Mailing_BAO_Mailing", (Array:54))
#21 /var/www/events/administrator/components/com_civicrm/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_mailing_create((Array:53))
#22 /var/www/events/administrator/components/com_civicrm/civicrm/Civi/API/Kernel.php(169): Civi\API\Provider\MagicFunctionProvider->invoke((Array:9))
#23 /var/www/events/administrator/components/com_civicrm/civicrm/Civi/API/Kernel.php(100): Civi\API\Kernel->runRequest((Array:7))
#24 /var/www/events/administrator/components/com_civicrm/civicrm/api/api.php(23): Civi\API\Kernel->runSafe("Mailing", "create", (Array:53), NULL)
#25 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Utils/REST.php(404): civicrm_api("Mailing", "create", (Array:53))

But if this happens so that the cronjob can't find the mailing, how can "Run now" do that?

And what field in which table is it that's missing? My SQL is a bit rusty...

How can I repair it?

Here's the complete log:

Jun 15 10:43:40  [info] $Fatal Error Details = Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => exceptionHandler
        )
    [code] => -19
    [message] => DB Error: no such field
    [mode] => 16
    [debug_info] =>
INSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )
SELECT ANY_VALUE(265), ANY_VALUE(i.contact_id), ANY_VALUE(i.phone_id)
FROM       civicrm_contact contact_a
INNER JOIN I_1253 i ON contact_a.id = i.contact_id
            INNER JOIN civicrm_email e ON e.id = i.email_id
           WHERE contact_a.is_deleted = 0
            GROUP BY e.email
ORDER BY   MIN(i.contact_id), MIN(i.phone_id)
 [nativecode=1054 ** Unknown column 'i.email_id' in 'on clause']
    [type] => DB_Error
    [user_info] =>
INSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )
SELECT ANY_VALUE(265), ANY_VALUE(i.contact_id), ANY_VALUE(i.phone_id)
FROM       civicrm_contact contact_a
INNER JOIN I_1253 i ON contact_a.id = i.contact_id
            INNER JOIN civicrm_email e ON e.id = i.email_id
           WHERE contact_a.is_deleted = 0
            GROUP BY e.email
ORDER BY   MIN(i.contact_id), MIN(i.phone_id)
 [nativecode=1054 ** Unknown column 'i.email_id' in 'on clause']
    [to_string] => [db_error: message="DB Error: no such field" code=-19 mode=callback callback=CRM_Core_Error::exceptionHandler prefix="" info="
INSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )
SELECT ANY_VALUE(265), ANY_VALUE(i.contact_id), ANY_VALUE(i.phone_id)
FROM       civicrm_contact contact_a
INNER JOIN I_1253 i ON contact_a.id = i.contact_id
            INNER JOIN civicrm_email e ON e.id = i.email_id
           WHERE contact_a.is_deleted = 0
            GROUP BY e.email
ORDER BY   MIN(i.contact_id), MIN(i.phone_id)
 [nativecode=1054 ** Unknown column 'i.email_id' in 'on clause']"]
)

Jun 15 10:43:40  [info] $backTrace = #0 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/Error.php(944): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 [internal function](): CRM_Core_Error::exceptionHandler(Object(DB_Error))
#2 /var/www/events/administrator/components/com_civicrm/civicrm/packages/PEAR.php(921): call_user_func((Array:2), Object(DB_Error))
#3 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB.php(985): PEAR_Error->__construct("DB Error: no such field", -19, 16, (Array:2), "\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
#4 /var/www/events/administrator/components/com_civicrm/civicrm/packages/PEAR.php(575): DB_Error->__construct(-19, 16, (Array:2), "\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
#5 [internal function](): PEAR->_raiseError(Object(DB_mysqli), NULL, -19, NULL, NULL, "\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...", "DB_Error", TRUE)
#6 /var/www/events/administrator/components/com_civicrm/civicrm/packages/PEAR.php(224): call_user_func_array((Array:2), (Array:8))
#7 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/common.php(1905): PEAR->__call("raiseError", (Array:7))
#8 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -19, NULL, NULL, "\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...", "DB_Error", TRUE)
#9 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/mysqli.php(933): DB_common->raiseError(-19, NULL, NULL, NULL, "1054 ** Unknown column 'i.email_id' in 'on clause'")
#10 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliRaiseError()
#11 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/common.php(1216): DB_mysqli->simpleQuery("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
#12 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php(2446): DB_common->query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
#13 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php(1635): DB_DataObject->_query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
#14 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php(362): DB_DataObject->query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
#15 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php(1315): CRM_Core_DAO->query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...", TRUE)
#16 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Mailing/BAO/Mailing.php(565): CRM_Core_DAO::executeQuery("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...", (Array:1))
#17 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Mailing/BAO/Mailing.php(1791): CRM_Mailing_BAO_Mailing::getRecipients("1253", "265", TRUE, "1", "sms")
#18 [internal function](): CRM_Mailing_BAO_Mailing::create((Array:54))
#19 /var/www/events/administrator/components/com_civicrm/civicrm/api/v3/utils.php(1284): call_user_func_array((Array:2), (Array:1))
#20 /var/www/events/administrator/components/com_civicrm/civicrm/api/v3/Mailing.php(70): _civicrm_api3_basic_create("CRM_Mailing_BAO_Mailing", (Array:54))
#21 /var/www/events/administrator/components/com_civicrm/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_mailing_create((Array:53))
#22 /var/www/events/administrator/components/com_civicrm/civicrm/Civi/API/Kernel.php(169): Civi\API\Provider\MagicFunctionProvider->invoke((Array:9))
#23 /var/www/events/administrator/components/com_civicrm/civicrm/Civi/API/Kernel.php(100): Civi\API\Kernel->runRequest((Array:7))
#24 /var/www/events/administrator/components/com_civicrm/civicrm/api/api.php(23): Civi\API\Kernel->runSafe("Mailing", "create", (Array:53), NULL)
#25 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Utils/REST.php(404): civicrm_api("Mailing", "create", (Array:53))
#26 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Utils/REST.php(641): CRM_Utils_REST::process((Array:3), (Array:51))
#27 [internal function](): CRM_Utils_REST::ajax()
#28 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(276): call_user_func((Array:2))
#29 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:12))
#30 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3))
#31 /var/www/events/administrator/components/com_civicrm/civicrm.php(121): CRM_Core_Invoke::invoke((Array:3))
#32 /var/www/events/administrator/components/com_civicrm/civicrm.php(40): civicrm_invoke()
#33 /var/www/events/libraries/cms/component/helper.php(394): require_once("/var/www/events/administrator/components/com_civicrm/civicrm.php")
#34 /var/www/events/libraries/cms/component/helper.php(369): JComponentHelper::executeComponent("/var/www/events/administrator/components/com_civicrm/civicrm.php")
#35 /var/www/events/libraries/cms/application/administrator.php(98): JComponentHelper::renderComponent("com_civicrm")
#36 /var/www/events/libraries/cms/application/administrator.php(156): JApplicationAdministrator->dispatch()
#37 /var/www/events/libraries/cms/application/cms.php(265): JApplicationAdministrator->doExecute()
#38 /var/www/events/administrator/index.php(51): JApplicationCms->execute()
#39 {main}
  • What do you mean by "we're now at 4.7.17 and 4.7.20"? You can only be a one version ... or do you mean you are seeing the same problems on two different systems and one is 4.7.17, the other 4.7.20? – Aidan Jun 12 '17 at 8:40
  • Well, we could have had two installations, right? ;-) We don't, but the same thing happens in both 4.7.17 and after upgrading to 4.7.20. – thoni56 Jun 12 '17 at 9:30
  • What output do you get from cron? (you may need to change the cron entry to avoid discarding all the output). I've seen these symptoms when the cron job runs out of memory – Aidan Jun 12 '17 at 10:11
  • What would I need to change to ensure I get all output? I do get a mail from the cronjob execution with a PHP notice, wouldn't any other output go into that mail too? – thoni56 Jun 12 '17 at 13:07
  • Output can go to STDOUT and STDERR and it is possible to redirect either or both to mail. However, if you're getting the PHP notice then you should see any memory issues, so it's probably not that. – Aidan Jun 13 '17 at 8:45

Your Answer

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

Browse other questions tagged or ask your own question.