Don't re-emit logical_date when previous data_interval is zero-length#66132
Merged
Conversation
Lee-W
reviewed
Apr 30, 2026
Member
Lee-W
left a comment
There was a problem hiding this comment.
Overall, looks good, but will need to take a look at the failed tests
…ngth When a DAG is migrated from CronTriggerTimetable (point-in-time) to CronDataIntervalTimetable, the latest run's data_interval has ``start == end``. ``_DataIntervalTimetable.next_dagrun_info`` would then align ``start`` onto that same point, producing a new run whose ``logical_date`` collides with the existing one. The scheduler logged "run already exists; skipping dagrun creation" and looped until the next cron boundary, sometimes silently skipping a scheduled run. Detect the zero-length previous interval and advance ``start`` by one period so the next run gets a fresh ``logical_date``. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- test_bulk_write_to_db_max_active_runs and test_next_dagrun_after_fake_scheduled_previous: switch synthetic zero-length data_intervals to realistic non-zero ones and update expected values. - test_schedule_tis_start_trigger: drop stale xfail (XPASS)
9827701 to
fe0103e
Compare
Lee-W
reviewed
Apr 30, 2026
uranusjr
reviewed
Apr 30, 2026
kaxil
approved these changes
May 1, 2026
Expand the inline comment in `_DataIntervalTimetable.next_dagrun_info` to explain the CronTrigger → CronDataInterval transition that produces a zero-length previous interval, and note in the `create_cron_data_intervals` config description that switching from CronTrigger to CronDataInterval skips one period past the most recent CronTrigger run.
Contributor
Backport successfully created: v3-2-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
Member
Author
|
And just for posterity, why formalizing this is better than blowing errors through the whole overlapping period? Well, if you have more dags in this scenario than |
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.
What's the bug
_DataIntervalTimetable.next_dagrun_infoaligns the next run'sstartontodata_interval.endof the previous run. When that previous interval is zero-length (start == end),startlands on the same point as the existing run'slogical_date, so the scheduler tries to create a run that collides with the existing one and logs:It then calls
calculate_dagrun_date_fields(last_automated_run=existing_run)to advance — which feeds the same zero-length interval back in and recomputes the same value. The scheduler loops on the skip warning until the next cron boundary nudges_skip_to_latestto a different result, at which point the gate may have already rolled past the slot — so the intended run is silently skipped.When does this happen?
Zero-length
data_intervals are the normal output ofCronTriggerTimetable(point-in-time) but never ofCronDataIntervalTimetable(windowed, validated> 0). They appear on aCronDataIntervalTimetableDAG when its scheduling history was produced byCronTriggerTimetableand the DAG later switches toCronDataIntervalTimetable— for example, when[scheduler] create_cron_data_intervalsis flipped fromFalse(Airflow 3 default) toTrueafter some runs have already been created.The fix
In
_DataIntervalTimetable.next_dagrun_info, after computingstart, if the previous interval was zero-length andstartfalls on it, advancestartby one period so the new run gets a freshlogical_date.The guard only fires for
_DataIntervalTimetablesubclasses (CronDataIntervalTimetable,DeltaDataIntervalTimetable).CronTriggerTimetable/DeltaTriggerTimetableextend a separate_TriggerTimetablebase with its ownnext_dagrun_infoand never go through this code path, so their normal zero-length output is unaffected.Tests
Added
test_zero_length_last_interval_does_not_re_emit_logical_dateparametrized oncatchup ∈ {True, False}— both branches converge on the same expected interval, demonstrating the guard absorbs the difference between the two paths into the previous-run handling.related: #59618
Was generative AI tooling used to co-author this PR?