-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
Cron jobs can be missed if deploys are timed just right #1484
Comments
Briefly, I'm imagining that there could be a configuration like I also wonder if it should have a similar lookahead where it's like "if the cron will start in the next [lookback-period] don't bother either" because I imagine if the job is being run every 1 minute or something rapidly like that, it shouldn't be necessary. It's more when the cron entry is like once per day that it's a problem, I imagine. |
Sounds like it'd work! Seems the time window value would be determined by the longest possible downtime you'd take during deployment (I suppose ideally this is 0) Ok obviously huge change... but would it be totally nuts to try and run cron scheduling through ActiveJob's API? Job.set(wait_until: next_cron_at).perform_later Altho hm I guess you'd have to wrap the job somehow so you could tell it to reschedule for the next occurrence after executing. It'd be cool if the cron manager could just boot up, schedule upcoming crons, and be done... possibly even removing the need for the dedicated thread? |
The way that GoodJob's cron works is intentional, but it is a design decision. GoodJob Cron's design is to be analogous to Unix System Cron, which differentiates between the scheduler and the task. That makes it possible to enqueue jobs at every scheduled time, and not just at the time the that a job (eventually) executes. That separation also makes it easy to cancel or change the schedule without having to search for a waiting job and then find/modify/destroy it. Also:
Sorry, I know that's TMI, but wanted to explain why it is the way it is 😄 Maybe I'd do it differently if I did it again, but only maybe. I think Solid Queue's implementation is interesting/different because it does put it all in the database (whereas GoodJob generally tries to keep stuff in configuration): https://github.com/rails/solid_queue/blob/main/test/dummy/db/schema.rb#L97 |
thanks for the informative response! this helps us evolve our approach both to how we deploy our workers as well as how we queue up our jobs. |
yes, thanks for the explanation 🙏 much appreciated and thanks for |
@jjb helpfully shared an example in sidekiq-cron, which has nice naming ("reschedule_grace_period"): sidekiq-cron/sidekiq-cron#465 Also TIL about Fugit "within": floraison/fugit@89d102d |
I have a PR up for this in #1488 |
TL;DR
just glancing at the code in CronManager, this seems possible (albeit unlikely), depending on very specific timing
I would think in a blue-green deployment world, this would not be possible 🤔 (but apparently our heroku worker deployments are not blue-green)
The text was updated successfully, but these errors were encountered: