From cda629078bb7cd07c519a12a8d993fbf68b85624 Mon Sep 17 00:00:00 2001 From: Robin Edwards Date: Thu, 21 Oct 2021 12:31:45 +0100 Subject: [PATCH] Fixes #18487 When a dag has catchup=False we want to select the max value from the earliest date and the end of the last execution period. Thus if a dag is behind schedule it will select the latest execution date. --- airflow/timetables/interval.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/airflow/timetables/interval.py b/airflow/timetables/interval.py index 8f5c3f1032a29..0dd7ffdbf136c 100644 --- a/airflow/timetables/interval.py +++ b/airflow/timetables/interval.py @@ -81,9 +81,15 @@ def next_dagrun_info( return None start = self._align(earliest) else: - # There's a previous run. Create a data interval starting from when - # the end of the previous interval. - start = last_automated_data_interval.end + # There's a previous run. + if earliest is not None: + # Catchup is False or DAG has new start date in the future. + # Make sure we get the latest start date + start = max(last_automated_data_interval.end, earliest) + else: + # Create a data interval starting from when the end of the previous interval. + start = last_automated_data_interval.end + if restriction.latest is not None and start > restriction.latest: return None end = self._get_next(start)