Open polarmt opened 1 year ago
that celery version is unsupported. also latest release is 2.4
Are you certain that this is still not an issue? All of the code that I posted under Detailed Information
is referenced from the current master
branch other than the Django code:
Is there code that prevents this call stack from running?
btw, It seems I prematurely concluded the issue. my apologies. can you create a PR with possible fix suggested?
Thanks for reopening! I have submitted the PRs here:
https://github.com/celery/django-celery-beat/pull/605 https://github.com/celery/celery/pull/7901
Summary:
Exact steps to reproduce the issue:
CELERY_TIMEZONE
equal toAmerica/Los_Angeles
IntervalSchedule
task runs between 1 AM and 2 PM on the day that daylight savings ends. In our case, this was 2022-11-06.An easier way to reproduce this issue is by running the following script in the shell (
python manage.py shell
):Detailed information
We were able to pinpoint the root cause after investigating the issue.
IntervalSchedule
will define thenowfun
function asmake_aware
(Source)now()
function insidecelery/schedules.py
will call thenowfun
, subsequentlymake_aware
(Source)make_aware
function will call themake_aware
function fromdjango/utils/timezone.py
without passing inis_dst
as a parameter (Source)make_aware
function will calllocalize
frompytz/timeinfo.py
(Source)localize
will find two timezones associated with thedatetime
(Source)is_dst
is undefined, the function will throw anAmbiguousTimeError
(Source)We have many Celery beat tasks running throughout the day. Because of this exception, we were not even able to start the Celery beat scheduler creating an outage for two hours. We had alerts to catch the issue as soon as it occurred, but there would have been a longer outage had we not caught the issue earlier.
Possible Solutions
We were wondering if there is a way to configure the Celery beat such that the
IntervalSchedule
tasks will run despite the fact that the time may be in two timezones. A change like the following would prevent such problems from occurring:Line to change
This might require some changes in the
remaining_estimate
. We can remove the following lines such that the time elapsed between the two timestamps is accurate:Line to change
If
last_run_at
is 1:15 AM PDT andnow
is 1:30 AM PST, then this should return 1 hour 15 minutes instead of 15 minutes.Note
I am aware of https://github.com/celery/django-celery-beat/issues/285. However, this does not solve our issue. Our issue is that the Celery beat scheduler will crash and fail to send tasks for an entire two hours due to the behavior of
make_aware
.