Preventing duplicate jobs

94 views
Skip to first unread message

Aman Gupta

unread,
May 4, 2020, 2:34:59 PM5/4/20
to delayed_job
Hey,

I am using delayed jobs and one issue that I am running into is that when I am adding, say 50K delayed jobs at the same time, it can get interrupted (like, by a deployment), and that code runs again and adds all those jobs again. There is some way I need to store an unique-id for the job, and prevent it from getting added twice. And I feel delayed Job table is the best place for that.

Is it possible to add custom fields to the table, and provide data for them with the delay() call?

Thanks,
Aman

hobbyDB Parker

unread,
Jun 9, 2020, 7:06:34 PM6/9/20
to delayed_job
We give the queue a name (in ours it's class || method) and do this before the jobs:
```ruby
unless DelayedJob.where(queue: "something || something").exists?
  ... do the work
end
```
Reply all
Reply to author
Forward
0 new messages