-
-
Notifications
You must be signed in to change notification settings - Fork 201
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
Fix cron double-enqueue because delay close to 0.01 and possibly clock-drift #1543
base: main
Are you sure you want to change the base?
Conversation
@bensheldon thanks for your help. |
@ccouton doublecheck my math, but I believe this line should prevent Concurrent Ruby from ever immediately running the task: |
Yes but it will be scheludled 0.02s after so a risk to be before the next at and so at the same of the previous at |
oh right! we do want to run it immediately if it is in fact in the past. I'll tweak that. |
Sorry i'm not clear enough, we have the case when clock drift cause an execution just before the real next scheduled at. Here i think this issue is not fixed. And maybe not easy to fix. We have ti execute it immeditaly if it's the first execution but if it's an other if cron_at is leather than current for me there is no reason to execute it? |
@ccouton this should (theoretically, assuming I did it right) prevent the I don't have a strategy for preventing the case where some delay causes a previously scheduled time to run at about the same time as the next scheduled time. I would say that if your schedule is at such a cadence that you frequently run into that (like every second), cron is maybe the wrong tool for that and it would be better to manage your own sleep loop. |
Fixes one problem in #1536
Case of clock drift and delay calculation result close to 0.001 so task is executed immediately which causes an unnecessary
duplicate key value violates unique constraint
-error even on single-process installations.