uranusjr commented on code in PR #66761:
URL: https://github.com/apache/airflow/pull/66761#discussion_r3793239538


##########
airflow-core/src/airflow/timetables/interval.py:
##########
@@ -111,18 +111,12 @@ def next_dagrun_info(
                 # Data interval starts from the end of the previous interval.
                 start = align_last_data_interval_end
 
-            # CronTriggerTimetable stores its runs as point-in-time intervals
-            # (start == end == logical_date). After a switch to a
-            # CronDataIntervalTimetable the aligned `start` lands back on that
-            # same logical_date, so without this guard we'd propose a run
-            # identical to the existing one — which collides with the
-            # (dag_id, logical_date) unique constraint and leaves the scheduler
-            # looping on "run already exists; skipping dagrun creation" until
-            # the next period elapses. Advance one period to skip past it.
-            if (
-                last_automated_data_interval.start == 
last_automated_data_interval.end
-                and start == last_automated_data_interval.start
-            ):
+            # When the Dag has a new schedule, aligning the previous interval
+            # end can land on (or before) the previous logical date. 
Re-emitting
+            # that logical date collides with the existing Dag run and leaves
+            # the scheduler looping on "run already exists; skipping dagrun
+            # creation". Advance one period to skip past it.

Review Comment:
   The comment explains what the guard does, but not why a single 
`_get_next(start)` step is always enough.
   
   `align_last_data_interval_end` is, by construction, the latest schedule 
boundary `<= last_automated_data_interval.end`, so the next boundary after it 
is guaranteed to be `> last.end > last.start` regardless of how far the 
schedule jumped, not just the adjacent-period case the new test covers.
   
   The guarantee provided here only holds when `start == 
align_last_data_interval_end`; when the earliest branch wins (`start = 
max(align_last_data_interval_end, earliest)` with `earliest > 
align_last_data_interval_end`), the single-step guarantee no longer follows 
automatically.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to