Download & Extend

Groundhog day: Repeat notifications when notify_cron() times out during _notify_send().

Project:Notify
Version:6.x-1.2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

My Drupal site was sending out repeat notifications every single time cron ran starting June 7th. I eventually just disabled the module, but recently I went digging through the code and log files to find out what was going on. It turns out that the 'notify_send_last' Drupal variable was never being updated, and I confirmed this was because of _notify_send() was repeatedly timing out based on the server limits. _notifiy_send() was consistently exceeding the default 30 seconds, timing out cron.php, then repeating itself on the next cron run since it never finished and never updated 'notify_send_last'.

I upped the limit from 30 seconds to 120 seconds on the virtual server... but it timed out *again*. I've upped the limit once more, but it seems like there must be a better behaviour for the module here.

First, maybe something changed in our June 7th update, and _notify_send() is taking way too long to complete (more than two minutes?). Let me know if you need more information here... I've got 239 rows in my 'dp_notify' table, this has happened first on a triple node update, but now on just a single node update. It seems to me like _notify_send() should not be taking more than two minutes to notify a few dozen users about a single node update...

Second, the default behaviour of notify_cron() seems quite prone to this error. Since there's only one timestamp, and it only ever gets updated if all notifications are sent successfully, it's groundhog day when a failure occurs halfway through and it just repeats this partial-notify-then-timeout every single cron run.

Might it be better if there were a timestamp per user, maybe? So that on partial-notify-then-timeout, the second cron job would pickup where notify_cron() left off, and so on each cron job until finished (rather than just repeating the first half of the list, spamming those users repeatedly, and never getting to the second half)?

Otherwise, it seems likely that many web servers don't let cron.php run for long periods of time, like120 second or more... I wonder if this is responsible for some of the other 'repeated notifications' bugs, because it's hard to track down why these notifications are repeating.

Happy to provide more information on my set up if it would help... I'm familiar with Drupal module development, but not too familiar with the notify code base beyond tinkering with notify_cron() and _notify_send() to confirm the cause of this problem.

Thanks.

nobody click here