How to resolve deserialization error in delayed job?

I believe this occurs when you run a job against an unsaved or deleted AR object since the deserialization for AR loads the record by id. An exception should probably be thrown if you attempt to delay a method on an unsaved AR object.


It's not really a deserialization error, it's an ActiveRecord record-not-found error on a simple Model.find(id) query.

If you want to know the details, log them in the delayed_job-2.1.3/lib/delayed/serialization/active_record.rb file, in the rescue statement, just before delayed-job stupidly raises the DeserializationError and throws the useful information away.


Michiel is right. Look at your handler field for objects like "!ruby/ActiveRecord:YourClassName"

Then check if objects can be retrieved via the primary key

From the console you can also test this out by doing something like:

# first job in your delayed queue
YAML.load(Delayed::Backend::ActiveRecord::Job.first.handler)