Search code examples
ruby-on-railsrubydelayed-job

delayed_job, jobs randomly disappears


We have a model that generates reports.

Each report can be very complicated and may take a long time to load. Therefore, we are using delayed_job to do this in background.

Everything works on my local computer but in our production environment jobs randomly disappear. They do not even exist in the delayed_job.log as success or failed. Delayed jobs are created but sometimes they are deleted without throwing any errors or doing the work.

This is the method in our model:

def generate_html
    ac = DelayedJobsController.new()
    tmp_html = ac.render_to_string partial: self.partial_path, object: self
    self.update_attributes(html: tmp_html, done: true)
end
handle_asynchronously :generate_html

Solution

  • After lots of work we found the problem.

    When we did run crontab -l and ps aux we cud see that two instances of delayed_job was running. After we killed the oldest one of them all worked like it should.