-
-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ActionMailer::MailDeliveryJob
executing twice
#329
Comments
@tobyaherbert thanks for reporting this and sharing the logs. This is unexpected. Do you have the logs preceding slightly preceding what you shared? On Line 11 and 12, there are these 2 lines, which is one GoodJob thread/worker fetching and locking the database record, and then verifying that it does have a lock. I only see this line once, and I'm curious if that is in the earlier in the logs of the other worker also fetching and verifying the lock:
I don't have an explanation, but I can walk you through my thinking in case it spurs some insight:
Could you confirm what version of Ruby and Rails you're using? And also whether you're using PgBouncer (a database connection pooler). And are you seeing this locally too, or just in production? Strange! |
@bensheldon Thanks for the prompt reply! Yep, I've got more logs from that period - Do you have somewhere I can send you a private link to see them? The project is using Rails 6.1.4 with Ruby 3.0.2. Here's a snapshot of the database.yml file:
Thanks again! |
Happy to help. You can email them to me: [email protected] |
Thanks for sending over those logs. I don't have an explanation for why this has happened. There isn't anything special about I haven't observed this happen before, and there is GoodJob test code that create a big concurrency load to surface these kinds of problems. Some suggestions:
I am stumped 🤔 |
@tobyaherbert I think I may have duplicated what you're seeing in #388. which is related to code reloading in the Development environment. I double-checked the logs you sent me, and they were for Development too. I just wanted to doublecheck that this behavior wasn't seen in the Production environment (because that would imply something different than #388). |
@bensheldon I got sidetracked and completely forgot to respond to you, apologies! Yes, we were testing our email sending feature in the development environment when we encountered the duplications. |
@tobyaherbert I totally understand. I have a fix for the problem released in |
@bensheldon Ah, that's great - I'll take a peek when I get a sec 👍 |
@tobyaherbert I'm closing this because of age. Please comment if you're still experiencing problems. |
I’ve recently noticed that some of the
ActionMailer::MailDeliveryJob
jobs enqueued using thedeliver_later
method appear to be executed twice despite being enqueued for delivery only once.GoodJob is configured with the default number of threads and Rails is scheduling the
ActionMailer::MailDeliveryJob
on the:default
queue.After a bit of digging through the log file, it looks like GoodJob could be executing the same job multiple times concurrently as the same ActiveJob UUID appears on both occurrences of the delivery job’s output which each have a different Message-ID.
I’ve uploaded a simplified copy of the log file here from which I’ve deduced the following:
As a temporary fix, I’ve moved all
ActionMailer::MailDeliveryJob
jobs to a:mailer
queue which has just one thread to prevent this from happening.Could this be a bug in GoodJob or is there something else I should check?
Thanks!
The text was updated successfully, but these errors were encountered: