Fix periodic tasks running twice the day after DST (Fix #1604)#4403
Merged
thedrow merged 1 commit intocelery:masterfrom Nov 27, 2017
Merged
Fix periodic tasks running twice the day after DST (Fix #1604)#4403thedrow merged 1 commit intocelery:masterfrom
thedrow merged 1 commit intocelery:masterfrom
Conversation
…elery#1604) When computing the remaining time after DST change, last_run_at time was localized in the previous time zone (before DST) The resulting end date was then also localized in the previous time zone In case UTC offets are different, Replace tzinfo with the current one
Closed
vbarbaresi
added a commit
to opendatasoft/celery
that referenced
this pull request
Oct 17, 2018
…elery#1604) (celery#4403) When computing the remaining time after DST change, last_run_at time was localized in the previous time zone (before DST) The resulting end date was then also localized in the previous time zone In case UTC offets are different, Replace tzinfo with the current one (cherry picked from commit 89b0b46)
Photonios
pushed a commit
to SectorLabs/celery
that referenced
this pull request
Feb 21, 2019
…elery#1604) (celery#4403) When computing the remaining time after DST change, last_run_at time was localized in the previous time zone (before DST) The resulting end date was then also localized in the previous time zone In case UTC offets are different, Replace tzinfo with the current one
18 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The issue was with celery running with UTC enabled, and a timezone with DST.
When computing the remaining time after DST change,
last_run_attimewas localized in the previous time zone (before DST)
The resulting end date was then also localized in the previous time zone.
So the task was running two times (running an hour early, then on the correct time)
In case the DST was starting the night before, the task was running an hour late the day after.
Proposed fix
Use the relevant time zone to compute the remaining time:
in case UTC offets are different between now and the previous run, replace tzinfo of the previous run with the current one.
There could be undesirable side-effects: if we change timezone settings with the database scheduler. But this wasn't supported anyway and required a reset.