Fix infinite cron trigger fires during DST fall-back transition#2865
Merged
Conversation
When computing next fire time in CronExpression.GetTimeAfter, ambiguous local times during DST fall-back transitions were assigned the DST (summer) UTC offset, resulting in a UTC time that was before the input. This caused triggers to always compute a next fire time in the past, leading to infinite refires. Fix: after computing the UTC result, if it falls before afterTimeUtc and the local time is ambiguous, use the standard (non-DST) offset instead — the minimum of the two ambiguous offsets — which corresponds to the second (post-fallback) occurrence of the ambiguous local time. Adds regression test ShouldNotFireInfinitelyAfterDstFallBackTransition reproducing the Amsterdam/Europe scenario from the issue report. Co-authored-by: lahma <[email protected]>
|
Copilot
AI
changed the title
[WIP] Fix infinite trigger fires after switching from DST to ST
Fix infinite cron trigger fires during DST fall-back transition
Mar 5, 2026
lahma
marked this pull request as ready for review
March 8, 2026 18:31
lahma
added a commit
that referenced
this pull request
Mar 8, 2026
When computing next fire time in CronExpression.GetTimeAfter, ambiguous local times during DST fall-back transitions were assigned the DST (summer) UTC offset, resulting in a UTC time that was before the input. This caused triggers to always compute a next fire time in the past, leading to infinite refires. Fix: after computing the UTC result, if it falls before afterTimeUtc and the local time is ambiguous, use the standard (non-DST) offset instead — the minimum of the two ambiguous offsets — which corresponds to the second (post-fallback) occurrence of the ambiguous local time. Adds regression test ShouldNotFireInfinitelyAfterDstFallBackTransition reproducing the Amsterdam/Europe scenario from the issue report. Co-Authored-By: Claude Opus 4.6 <[email protected]>
2 tasks
lahma
added a commit
that referenced
this pull request
Mar 8, 2026
When computing next fire time in CronExpression.GetTimeAfter, ambiguous local times during DST fall-back transitions were assigned the DST (summer) UTC offset, resulting in a UTC time that was before the input. This caused triggers to always compute a next fire time in the past, leading to infinite refires. Fix: after computing the UTC result, if it falls before afterTimeUtc and the local time is ambiguous, use the standard (non-DST) offset instead — the minimum of the two ambiguous offsets — which corresponds to the second (post-fallback) occurrence of the ambiguous local time. Adds regression test ShouldNotFireInfinitelyAfterDstFallBackTransition reproducing the Amsterdam/Europe scenario from the issue report. Co-authored-by: Claude Opus 4.6 <[email protected]>
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.



During the first hour after a DST fall-back transition, cron triggers with a local timezone would fire in an infinite loop because
GetTimeAftercomputed aNextFireTimeUtcthat was one hour in the past.Root Cause
CronExpression.GetTimeAfterconverts the input UTC time to local time, advances the cron cursor, then maps back to UTC viaTimeZoneUtil.GetUtcOffset. During fall-back, the resulting local time is ambiguous (e.g.,02:01:00in Amsterdam exists as both CEST+2 and CET+1).GetUtcOffsetalways picks the DST (Max) offset for ambiguous times — the first occurrence — producing a UTC result before the input:Fix
After computing the UTC result in
GetTimeAfter, if it falls beforeafterTimeUtcand the computed local time is ambiguous, use the standard (non-DST) offset —Min()of the ambiguous offsets. DST always shifts UTC offset by +1h, soMax()is always DST andMin()is always standard, regardless of hemisphere.Changes
src/Quartz/CronExpression.cs— Added post-computation guard inGetTimeAfterto select the standard offset when the DST offset produces a result in the past.src/Quartz.Tests.Unit/DaylightSavingTimeTests.cs— Added regression testShouldNotFireInfinitelyAfterDstFallBackTransitionreproducing the Amsterdam/October 29, 2023 scenario from the issue.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.