1

This sounds like #11603 but is not about the end date, as was the answer there. Also reported on Civi Gitlab.

Does anyone have thoughts on this issue or what it may take to fix it?

Overview

We're seeing scheduled reminders occurring more than once. In our case we have reminders set up before expiry of memberships (e.g. 7 days before). In some cases when we look at the activities for a contact, there are multiple entries for a reminder (all with status "completed"). For a given contact these show up once per cron run, for multiple subsequent cron intervals (i.e. 1 activity each hour for multiple hours in a row).

These occurrences coincide with failures of the send_reminder scheduled job. Looking at the job log shows this result:

Entity: Job Action: send_reminder

Summary
Finished execution of Scheduled reminders sender with result: Failure, Error message: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

Details

Parameters parsed (and passed to API method): 
a:1:{s:7:"version";i:3;}

Full message: 
Finished execution of Scheduled reminders sender with result: Failure, Error message: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

It appears when this failure happens for the scheduled job, the contact still get an activity for their scheduled reminder, and they continue to do so each cron run (in our case this scheduled job is set to be hourly), until the job shows a success (at this point is the last activity they get).

Looking at the code in CRM_Core_BAO_ActionSchedule it appears that the email is sent (sendReminderEmail) before the activity is created (createMailingActivity), so I expect the contact has in fact received multiple emails, NOT that multiple activities were created without emails being sent.

Without digging further, I'm guessing maybe civi considers ALL reminders have failed in the batch if the scheduled job fails, even if some were sent out and the job failed partway through.

Reproduction steps

In our case the "MySQL server has gone away" db error appears to be causing this, which of course is a problem unto itself, but would be preferable if Civi could handle this situation better.

Current behavior

Contact receives multiple emails and activity entries when only 1 should occur. They are getting n+1 of these, where n is the number of times the scheduled job fails.

Expected behavior

It would be preferable for only 1 email to be sent to each contact, and that if the job fails, only the unsent emails are then sent later.

Contacts should only get 1 email reminder, and 1 "completed" activity. Maybe they should also get other activities for the failed cron runs with another status such as "failed" or "cancelled", but that probably doesn't matter much either way.

Environment information

  • CiviCRM: 5.23.0
  • PHP: 7.2.29
  • CMS: Drupal 7.69
  • Database: MySQL 5.7.29

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.