-
Notifications
You must be signed in to change notification settings - Fork 457
PeriodicTasks with a TZ are not running #875
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
Comments
cc JinRiYao2001 |
Thanks for the report |
@radoshi Thank you for identifying the crux of the issue. We are experience failures on our end, too. I could not find out the root-cause as I thought it was with my arguments being passed to tasks. |
@radoshi @auvipy We've experienced tasks not running as well, but it's a bit of a mystery what the underlying cause is, as I've had ones with timezones set that work, and UTC ones that don't. Below is a screenshot of our periodic tasks and when they last ran. We deployed 2.8.0 on 20 April. Edit: The second and third items on the screenshot should be ignored, they have correctly not run yet. |
I'm experiencing the same issue with the new 2.8.0 release. It's also not quite clear why, it seems to happen to tasks with timezone and UTC, some of them are just not scheduled while others run fine. |
Just adding that we are experiencing the same issue, some of our PeriodicTasks did not run this morning but got picked up as soon as we downgraded to 2.7.0. |
I wanted to bring up a potential concern with the exclusion logic in The current implementation excludes crontab tasks based on the server's local time, which might lead to unintended issues for UTC or timezone-aware tasks. Specifically:
This approach may unintentionally skip tasks that are scheduled correctly based on their respective timezones. Suggested Fix: For UTC tasks, avoid converting them to the server's local time and compare directly against UTC time. For timezone-aware tasks, convert them to the server's local time and then apply the exclusion check. Performance Consideration: Cache the time zone conversion during task creation or update, so that we don't repeatedly convert the time on every exclusion check. This would keep the logic correct without incurring significant performance overhead. I'd be happy to help with a patch to implement this change and create tests for it. Let me know if you'd like me to proceed with this. |
@radoshi |
we have this draft fix #877, can anyone try it ? |
@auvipy I'm able to take care of this and run some quick tests based on my observations. However, I’ll be available on Friday or Saturday. Please let me know if that works for the timeline. |
I am available on saturday as well |
We are also having problems, and I noticed that setting the cron for e.g. 59 14 * * * schedules the task while using e.g. 0 15 * * * does not work. Might be ralated to #875 (comment) |
I don't think #877 will be enough. This problem is that this line compares excluded hours (preferably UTC with the change in #877) to the hour field of crontab which is in the timezone the user specified, not in UTC
The UTC hour could be computed every query with something like that Azurency@ce00300 (this is just something I tried, to see if that worked on some tasks I was scheduling). |
it seems that, reverting that PR would be best option right now? |
why don't you send a draft pr? |
With the current release version being quite broken, are there plans to revert the offending commit and release a hotfix and/or revert back to 2.7.0? It seems like a generally bad idea to have the latest/default version of the lib contain such an error that breaks the fundamental reason for using said lib. |
Encountering the same problem. All tasks in Periodic Tasks with tz aware crontab scheduler are not fetched in |
I'm in a pickle as well because 2.7.0 doesn't support Django 5.2 so I'd have to back out of multiple things to make this work. A 2.8.1 hotfix removing the nonfunctioning optimization (fc64741) would take the pressure off so you can optimize the optimization with ample time and test coverage.
|
Either option would be really helpful so we can get to Django 5.2:
|
we got a new PR to fix this, #879 please feel free to review it. once this is ready we will make a hot fix early next week |
@alirafiei75 with our current setup, it's non-trivial to test stuff outside production unfortunately. |
you can just review it as well |
@auvipy done. I generally don't review OSS stuff, this is the first, but I hope that's helpful. Please feel free to ignore any and all comments. |
Running that branch in production has fixed our issue with the TZs. Here's the entry in our .in file if anyone else wants to try:
|
I'm also having issues with 2.8.0 and ClockedSchedule (see #879 (comment)). Maybe it's better to release a quick 2.8.1 hotfix reverting #835 for now ? |
Thanks that was a very good review |
Yes, will release a hotfix after the new PR is merged |
When should we see 2.8.1 published? |
We're seeing something that smells a lot like this issue - hopefully it's fixed, but in case not and for the record, we have several crontab schedules in the Another, Edit to add: from skimming the PR and the discussion, it looks like this is all consistent with the issue. |
should be fixed by #879 but please let us know if otherwise. |
@auvipy thank you! Will you be releasing 2.8.1 with this fix soon? |
Yes |
Also note, since this includes optimization code our heartbeat checker failed. This no longer triggers every few secs:
That statement about every few secs is now:
To anyone wanting to check that with a k8s probe, we run this script:
|
@auvipy when should we expect 2.8.1? Anyway we can use the fix until the official relase is out? |
I am having a similar issue in 2.7.0, after some time the scheduler stops working at random, I have detailed the issue here: celery/celery#9622 Do you think it is related ? |
This issue should be fixed in main branch, you check |
@auvipy any eta for dot release? |
Got another related pr, so Hopefully after merging that |
Hi guys! we got another PR which is related #886! would love to have your thoughts and reviews on that |
@auvipy I can hardly test this on main as my issue only appears on prod at random |
Hi @auvipy . Thanks to everyone for addressing this issue in a timely manner. This surely is a nasty bug. When reading through the thread, the issues we are experiencing with some tasks running and others not describes exactly what we've been noticing in our system. I am eager for version 2.8.1. When should we expect this release? Moreover, do you have a suggested stopgap solution for the meanwhile since downgrading to 2.7.0 doesn't work for us because it does not support Django 5.2? |
We switched our schedules to the equivalent in UTC and this avoids the issue. (If DST shifts are important to your tasks this might not be ideal, I suppose, but most time zones won't shift relative to UTC for a few months...) I'm not certain that this works for all possible server timezones though. |
It's my understanding that all PRs related to this issue were merged, so, is there some planned release date for 2.8.1? |
While working towards 2.8.1, can 2.8.0 be yanked on pypi to indicate it is broken? |
Agreed - frankly cannot believe 2.8.0 is still available in such a broken state. Seems like a bad move. |
we got a new release https://pypi.org/project/django-celery-beat/2.8.1/ and going to yank the 2.8.0. thanks to all who reported, reviewed, contributed code/test, and also shared your valuable opinion. |
hi guy! would you mind checking this PR and report that this do not create any regression #896 ? |
Hi,
We noticed a failure on all periodic tasks with a timezone set, after moving to 2.8.0. We believe this a regression caused by #844
Any tasks that keyed to a
CrontabSchedule
set in a specific timezone are not being scheduled.For example:
This task did not get scheduled.
IntervalSchedules seem fine. CrontabSchedule with a UTC also seems fine.
We're happy to try to do a minimal repro, though its a bit complicated, if that would be helpful.
The text was updated successfully, but these errors were encountered: