Looking through the codebase, I noticed that Time.now is used to calculate the remaining time to sleep between the iterations of the delayed job processing loop.
This could result in undefined behaviour, as Time.now reports wall time, which could change and get updated at any point.
Looking through the codebase, I noticed that
Time.now
is used to calculate the remaining time to sleep between the iterations of the delayed job processing loop.This could result in undefined behaviour, as
Time.now
reports wall time, which could change and get updated at any point.This is the code I'm talking about: https://github.com/resque/resque-scheduler/blob/master/lib/resque/scheduler.rb#L416
If the system's time was updated and moved backward one hour between the two calls to
Time.now
, the scheduler would sleep for one hour.One way to mitigate this issue would be to use monotonic time to measure the remaining seconds to sleep like so: