ruby-on-railsdelayed-joboctopus

Rails and Octopus gem and issues with delayed job


I use Octopus gem. If I call a delayed method on an active record object, I get the following error:

Delayed::DeserializationError:
Job failed to load: undefined method `[]' for nil:NilClass

The error only occurs if Octopus is turned on.

Delayed jobs that don't have any reference to active record objects work as expected.

Is the only way to solve this issue to change all the code:

active_record_object.delay.trigger_custom_action(another_active_record_object)

with a dummy class that uses very primitive arguments, and reload active record objects inside the method?

class Jobs 
    def self.trigger_custom_action(id1, id2)
        active_record_object = Something.find(id1)
        another_active_record_object = Something.find(id2)
        active_record_object.trigger_custom_action(another_active_record_object)
    end
end
Jobs.trigger_custom_action(active_record_object.id, another_active_record.id)

Solution

  • We decided that we will use early versions of Rails 6 instead. We didn't find a way to fix the issues we had on worker dynos.