aross aross - 25 days ago 8
Ruby Question

delayed_job, jobs randomly disappears

We have a model who generate reports.

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

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
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 =
tmp_html = ac.render_to_string partial: self.partial_path, object: self
self.update_attributes(html: tmp_html, done: true)
handle_asynchronously :generate_html

Answer Source

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.