-
Notifications
You must be signed in to change notification settings - Fork 955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed jobs not correctly unlocked first time through (fast repeats) #63
Comments
Any thoughts on this ticket? Or am I just crazy? ;-) |
Sorry, I haven't had a chance to take a look at it yet. I'll try to in the next day or so. |
it's because the job has been locked with ar's class methods (update_all), and after that the locked_by and locked_at is setted (but no save is perform!) so when you call to unlock, for activerecord you are setting to the original value (nil, which is incorrect because in the database is not nil, is the value setted by update_all), so no save is done. |
Fix issue where dirty tracking prevented job from being properly unlocked Closed by e03a584 |
I've been tooling around with changing the backoff algorithm (and making the algorithm configurable), but in doing so, I noticed that failed jobs are invariably retried instantly anyway with the currently release (2.0.3) of delayed job.
After a whole bunch of yak shaving, I noticed that the locked_by attribute sometimes wasn't being correctly updated when a failed job was rescheduled. In
#reschedule
, it's doing:job.unlock
should have been settinglocked_by
to nil and, indeed in inspecting the objects, it seems to be settinglocked_by
to nil (it isn't before and it is after). However, the save operation isn't updating the locked_by in the db. I think this is ActiveRecord's dirty tracking being too clever. I made a quick change to#reserve_and_run_one_job
to change from:to:
which seems to do the trick, though I don't fully understand why. :-)
Can you see what's going wrong and if this is the right fix?
The text was updated successfully, but these errors were encountered: