You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inconsistent data_interval_start/data_interval_end behavior between manual and scheduled DAG runs #41014
I have a DAG with a schedule of "20 */3 * * *" and catchup=False.
This DAG was paused temporarily, such that we had the scheduled__2024-07-24T03:20:00+00:00 and scheduled__2024-07-24T09:20:00+00:00 runs, but the run in between was skipped.
We later wanted to manually trigger the missed DAG run. We used 2024-07-24 06:20:00+00 as the logical date in the DAG run trigger form, but this resulted in
Data interval start | 2024-07-24, 03:20:00 UTC
Data interval end | 2024-07-24, 06:20:00 UTC
This is the same interval as the scheduled__2024-07-24T03:20:00+00:00 run. The scheduled__2024-07-24T09:20:00+00:00 had
Data interval start | 2024-07-24, 09:20:00 UTC
Data interval end | 2024-07-24, 12:20:00 UTC
This indicates an inconsistency in the treatment of the logical date between manual and scheduled runs. For a scheduled run, the logical date is the data interval start date, but for manual DAG runs it is the data interval end date.
We were unable to trigger the DAG run with a logical date of 2024-07-24 09:20:00+00, which failed with The logical date 2024-07-24 09:20:00+00:00 already exists.
We ended up doing a manual backfill instead since we couldn't trigger a DAG run with the appropriate data interval.
What you think should happen instead?
Both manual and scheduled runs should treat the logical date the same way. I have no preference on whether it is the data interval start or end date as long as they're consistent.
How to reproduce
Create a DAG with a schedule of "20 */3 * * *" and catchup=False
Let one DAG run complete
Pause the DAG until after the next DAG run would have started
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
changed the title [-]Inconsistent data_interval_start/data_interval_end behavior between maual and scheduled DAG runs[/-][+]Inconsistent data_interval_start/data_interval_end behavior between manual and scheduled DAG runs[/+]on Jul 24, 2024
The behaviour is expected and (unfortunately) intended. When a run is scheduled, it is identified by its data interval, but a manually triggered run does not have a pre-defined interval to start with, so it is instead identified by the time it’s triggered (or the custom date you provide), and the data interval calculated from it. Notably, the data interval is calculated backwards because a run cannot start before the interval it covers ends, and calculating forward would force a trigger to wait for potentially a long time before it can actually kick start anything, which is not people want. This has been the behaviour since pre-historic times (in the sense that nobody really remembers who created it and why), and we couldn’t change it due to compatibility issues.
But you’ve come at the right time! Airflow 3 is set to start development next month, and it will be possible to break compatibility in a major version bump. I think there’s already an issue somewhere for this, or I’m going to create one if I can’t find it.
I think we can close this. The new “trigger” timetables fix this (and are the default for new Airflow deployments). We’re not going to change the old timetables since it would break to many existing workflows.
Activity
boring-cyborg commentedon Jul 24, 2024
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
[-]Inconsistent data_interval_start/data_interval_end behavior between maual and scheduled DAG runs[/-][+]Inconsistent data_interval_start/data_interval_end behavior between manual and scheduled DAG runs[/+]uranusjr commentedon Jul 31, 2024
The behaviour is expected and (unfortunately) intended. When a run is scheduled, it is identified by its data interval, but a manually triggered run does not have a pre-defined interval to start with, so it is instead identified by the time it’s triggered (or the custom date you provide), and the data interval calculated from it. Notably, the data interval is calculated backwards because a run cannot start before the interval it covers ends, and calculating forward would force a trigger to wait for potentially a long time before it can actually kick start anything, which is not people want. This has been the behaviour since pre-historic times (in the sense that nobody really remembers who created it and why), and we couldn’t change it due to compatibility issues.
But you’ve come at the right time! Airflow 3 is set to start development next month, and it will be possible to break compatibility in a major version bump. I think there’s already an issue somewhere for this, or I’m going to create one if I can’t find it.
eladkal commentedon Mar 14, 2025
@uranusjr is this one still planned for Airflow 3?
uranusjr commentedon Mar 14, 2025
I think we can close this. The new “trigger” timetables fix this (and are the default for new Airflow deployments). We’re not going to change the old timetables since it would break to many existing workflows.