As we discovered at #2131983: Sending full comment history in issue notification emails is impossibly expensive the code for generating the issue notification emails can be extremely expensive. I also think (without hard evidence) that this is one of the primary factors contributing to #2128261: Updating an issue is prohibitively slow :( (high latency on writes)
Sadly, #1618240: Consider deploying queue_mail for issue notification emails doesn't help since the problem isn't the actual sending, it's all the work that goes into generating the messages (and perhaps finding everyone who wants to be notified about a given update).
So, I've worked on a patch that adds a queue directly in project_issue for managing email notifications. During an issue update or a new comment, we simple enqueue the nid/cid duple that we need to send notifications for. I created a new drush command that drains this queue and actually sends the notifications. The behavior is controlled by the 'project_issue_notification_queue' variable, which defaults to FALSE, so sites have to opt-in to the queue behavior (once they setup something to run the new drush command "all the time").
Deployment instructions
Deploy the code
drush updb
drush vset project_issue_notification_queue TRUE # Or put this in settings.php or equivalent
drush cc drush
Create a jenkins job to keep calling the new drush command every minute. See for example: http://localhost:8080/view/Dev/job/dww7%20drain%20issue%20notification%2...
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 2139561-1.issue-notify-queue.patch | 7.34 KB | dww |
Comments
Comment #1
dwwI've tested this fairly heavily on a local site, but it's hard to manually cover all the permutations, none of this lends itself to automated testing, and we haven't been spending development effort on automated tests for Project* D7. :/ Therefore, I'd *love* another pair of eyes on this before I commit and deploy this.
Comment #2
dwwOddly my patch file didn't seem to stick with the last revision. Trying again. WTF?
Comment #3
dwwComment #4
dave reidWhy not use https://drupal.org/project/queue_mail rather than more custom code?
Comment #5
dave reidSigh, read the issue Dave...
Comment #6
dww/me hugs Dave Reid -- no worries.
This is now installed on http://dww7-drupal.redesign.devdrupal.org (along with the patch from #2135095: Follow button does not affect email notifications so that bug should be fixed there, too).
I added a section to the summary about deployment instructions.
If you can log in to the dev site and repair your email address to something valid, confirm it, and set that as your primary address, you should start seeing issue notifications.
I guess we can try to deploy this on a full staging site (maybe git7site is available?) to get a better sense of if it's working properly and to see if it improves the latency of updating an issue in a noticeable way.
Comment #7
dwwA note based on some testing on dww7. This is totally expected, but I wanted to explicitly describe the behavior here in case anyone is confused or thinks this will be a problem:
Now, the follow functionality only counts at the moment that the queue drainer job is running, not at the time the issue update is happening. So, if you add some comments, then unfollow, it's entirely possible/likely that you will *not* see the notifications for those comments, since by the time the queue is being drained, you've already unfollowed.
As I said, I think this makes sense and is not in any way a bug with the implementation, and there's really no good way for us to know if you were following or not when you posted a comment. Although, the act of adding a comment or updating the node will automatically make you follow it again. So, in theory, we should *always* generate a notification on your own comments. Except for the people who think you should *never* get those emails. ;) #667122: Manage e-mail notifications: Add option to not email the person who is making the update
Comment #8
dwwDid more testing on dww7 and didn't find any new problems. Was going to test this on staging, but that site is borked right now. tvn thought we should just plow ahead, push this live, and watch for problems.
http://drupalcode.org/project/project_issue.git/commit/612a7c1
Merged into bzr and deployed to production.
Setup http://localhost:8080/view/D.o/job/drupal.org%20drain%20issue%20notifica...
And finally, ran this on production:
The jenkins job thinks it's sending notifications now:
I'll keep a close eye on this for the next hour or so, but so far, it seems to be working okay.
Comment #9
dwwp.s. I asked killes in IRC, and he was happy with this new jenkins job running on www1, not util:
Comment #10
jthorson commentedAs a followup, after looking at the original code, I think we should look at building up batched bcc lists instead of 'mail per recipient', and greatly cut down the sheer number of emails which are actually generated.
(Admittedly, I haven't looked at the queue implementation yet, so if this was already done, please ignore me.)
Comment #11
dwwIt's unclear if that matters at all, but it might be worth opening an issue about optimizing the notification emails, and suggest that as one of the possible solutions to explore.
Thanks,
-Derek
Comment #12
drummNot sure if it matters now. Not selecting "Restrict where this project can be run" will run the job on any www server with an available executor. Only www servers are configured to take unbound jobs.
Comment #14
moshe weitzman commentedWas a custom Drush command really necessary here? It isn't a problem, but Drush core comes with a queue-run command which iterates over the items and delegates to the queue's declared 'worker callback' function.