collectiveidea / delayed_job

Database based asynchronous priority queue system -- Extracted from Shopify
http://groups.google.com/group/delayed_job
MIT License
4.82k stars 956 forks source link

Delayed::DeserializationError: Job failed to load: undefined class/module Spree::AccountSalesRecordMailer #1132

Closed MittalPatel-BTC closed 3 years ago

MittalPatel-BTC commented 3 years ago

@albus522: We are using delayed_job_active_record (4.1.3), Rails 5.2.3, and Ruby 2.6.3.

The job is created for sending account sales record emails. The strange part is that some emails are going perfectly without any issue but some emails in the job, are throwing below exception.

Delayed::DeserializationError: Job failed to load: undefined class/module Spree::AccountSalesRecordMailer. Handler: "--- !ruby/object:Delayed::PerformableMailer\nobject: !ruby/class

I also tried by changing the argument before we are passing the whole active record object and now I am using only the I'd of the active record object and pass it as an argument but still issue is not resolved.

Can anyone suggest a solution here? How can I resolve the issue?

Thanks in advance!

albus522 commented 3 years ago

Your worker process and queuing process are most likely out of sync code wise. You likely have an old worker lingering somewhere that does not have the new mailer class. In development code reloading within the worker process is automatic, but code reloading does not occur within production environments.

MittalPatel-BTC commented 3 years ago

@albus522: Thanks for your response!

In my server, multiple instances are running of the delayed job so each instance points to a different codebase and some of the instances are not loaded properly. This is the only reason I start facing the issue.

I have killed all instances of the delayed job and restarted a new instance also restarted everything on the server and now it's working fine. I have performed the below steps.

Check the delayed job processes on the server using

ps -aux | grep \delayed_job

Kill all process of the delayed job using

sudo kill -9 PROCESS_ID

Restart the fresh delayed job instance using

bin/delayed_job start

Then restart the server. Now everything works fine.