Mailing list emails could be processed twice

Issue #140 resolved
Martijn Luinstra created an issue

The implementation of process_mailinglist_queue in cron/process_mailinglist_queue.php doesn’t check the mailinglist status again once it starts processing.

This could lead to this scenario:

  1. Two mails to are queued between two consecutive cron job runs so they will be processed by the same job. The first is send to a big list (that takes longer than 5 minutes to process), the second can be send to any list.
  2. A first run of the job queries all “waiting” emails, which in this case is both. It starts processing the first mail, which is marked as with the status “processing”.
  3. 5 minutes later, a second run starts. It queries all “waiting” emails, which in this case is only the second email. It starts processing and marks the mail as such.
  4. When the first job is done processing the first mail, it will start processing the second mail. As it doesn’t check status, it will process it regardless of what the second run has done with the email. (It might even be send, but to the first job it’s status is still ‘waiting’).
  5. The first job will now also process the second email, so it is send twice.

This is a problem (obviously). Before processing an email, it should be verified with the DB that the mail is still waiting to be processed.

Comments (1)

  1. Log in to comment