Mautic Community Forums

Timed Email Sent Multiple Times

Hi,



I am having a simple campaign:

  1. Send an email on a fixed date
  2. Send another email on another fixed date (one week later)



    Here is the configuration of the campaign:
  • Campaign is based on a campaign with one contact segment
  • Campaign has 2 branches (1 for each email) originating from the contact segment
  • Both email actions have fixed points in time
  • The email actions were marked as marketing emails with 3 send attempts



    Problem: Today, after the first wave was sent out, I recognized that in some cases the same email was sent out 3 or 2 times (wrong), in some cases 1 time (correct).



    I experienced something similar with a timed email some weeks ago. Back then I thought I did some misconfiguration. Bur obviously it is a bug.



    Any ideas?



    Peter

Hi,

I am having a simple campaign:

  1. Send an email on a fixed date
  2. Send another email on another fixed date (one week later)

Here is the configuration of the campaign:

  • Campaign is based on a campaign with one contact segment
  • Campaign has 2 branches (1 for each email) originating from the contact segment
  • Both email actions have fixed points in time
  • The email actions were marked as marketing emails with 3 send attempts

Problem: Today, after the first wave was sent out, I recognized that in some cases the same email was sent out 3 or 2 times (wrong), in some cases 1 time (correct).

I experienced something similar with a timed email some weeks ago. Back then I thought I did some misconfiguration. Bur obviously it is a bug.

Any ideas?

Peter

Addition: The multiple emails are visible in the contact history of the affected contacts. This is really urgent as I will - again - lose contacts because of this.

Additions:

  • The multiple emails are visible in the contact history of the affected contacts
  • I am running Mautic 2.5.1 on this instance
  • In the campaign overview the correct number of contacts and emails is visible - in channels/emails the number of sent emails is higher

This is really urgent as I will - again - lose contacts because of this.

My impression: When I campaign starts with a timed action, it comes to the faulty behavior. I have another campaign with timed actions - but it starts with an immediate action - there it works fine.

Ah shish, could it have something to do with this? https://github.com/mautic/mautic/issues/3669

My crons run every minute at exactly the same time. :frowning:

:frowning: Yeah I’ve had issues in the past with such things. In the end, and this may not be perfect but works for me, is to set a cron script which detects collisions (so more than one script wont run) that then does each mautic process one after the other. Since doing that I’ve not had any issues.

@kgroves Would you mind sharing your cron script? I setup cron with pauses between the different calls. However, a collision detection would be nicer.

OK its not clever really (I like simple solutions). I will extract it from my private git and post it later. In the meantime the general idea of approach is something like this:

Test for a file existance. eg /tmp/mauticrunning

If not there then create it containing the PID of this process to prevent another running and then go through all of the usual crons one by one. At the end remove the file

If it does exist that means it may be running or its crashed. In that case do a check to see if the PID is still running. If it is then just exit, if not then remove the stale file.

Here you are. You may want to adjust to your own use but this should give you the idea for your own:

https://gist.github.com/kgroveshok/c95a40ed016a4e9dcb208494e62f852d

Thanks for sharing, @kgroves!

But are you sure, this does the trick? As far as I understood, the problem is that
a) job A must noch overtake itself and
b) job A and job B must not run parallel.

Your script prevents a but it does not prevent b - or am I wrong?

Only use that script as a single cron entry, remove all other cron entries. So what happens is that script (A) will run on whatever time you set, if its not finished by the time another one (B) wants to run then (B) will just abort.

And as each call to the mautic php scripts are in sequence then none of the mautic scripts will not hit one another at any time.

OK, I understand. Then it will work. Thanks again!

Anytime. Let me know if its not working for you though.