Skip to content

Fix periodic tasks running twice the day after DST (Fix #1604)#4403

Merged
thedrow merged 1 commit intocelery:masterfrom
vbarbaresi:master
Nov 27, 2017
Merged

Fix periodic tasks running twice the day after DST (Fix #1604)#4403
thedrow merged 1 commit intocelery:masterfrom
vbarbaresi:master

Conversation

@vbarbaresi
Copy link
Contributor

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_at time
was 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.

…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
@thedrow thedrow merged commit 89b0b46 into celery:master Nov 27, 2017
@vbarbaresi vbarbaresi mentioned this pull request Nov 27, 2017
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
@auvipy auvipy added this to the v4.2 milestone Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants