I think I’ve identified a race condition. I know that the sidekiq queue had a 10K second (~3 hour) latency. Messages are queued every 30 minutes:
So a digest gets queued in an hour-long queue. Half an hour later we test for whether to queue another digest, checking the last time that a message was sent:
The last digest is queued, but not sent, so last_emailed_at isn’t updated, so another message gets queued.
The solutions that I see are:
- this site gets faster hardware (beyond my control)
target_user_idssomehow searches the queue to see if there is a queued, unsent digest (seems really hard and won’t get into core in my lifetime).- Have the process that sends the digest do another check of
last_emailed_atbefore sending the digest (I think this might be the best long-term solution, but haven’t found that code) - I add a hook to modify
enqueue_digest_emails.rbto makeevery 30.minutessomething like4.hours(6 hours?) and hope that is enough time for the queue to get processed before it runs again.
Number 4 above seems like my only immediate solution. Is there some deleterious side effect that I am overlooking?
(I did recently increase db_shared_buffers from 10GB to 16GB for the 30GB on disk database. This might help, but I suspect that it won’t be enough. There are ~25K users at TL1 and above.)