manipatnam opened a new pull request, #64162:
URL: https://github.com/apache/airflow/pull/64162

   <!-- SPDX-License-Identifier: Apache-2.0
        https://www.apache.org/licenses/LICENSE-2.0 -->
   
   Fix `CronTriggerTimetable` ignoring `run_immediately` when `start_date` is 
set, simplify its
   semantics, and document the parameter properly.
   
   **Bug:** `run_immediately` was only respected on the very first run when 
`start_date=None`.
   When `start_date` was set (the common case), `_calc_first_run()` was skipped 
and the
   timetable always fell back to `align_to_prev(now)`, behaving as 
`run_immediately=True`
   regardless of the value passed. The fix ensures `_calc_first_run()` is 
always called on
   the first run, whether or not `start_date` is set.
   
   
   **Semantic fix:** `run_immediately=False` previously applied an undocumented 
auto-buffer window
   (10 % of the cron interval, minimum 5 min) identical to `None`, making 
`False` not mean what
   users expected. `False` now cleanly means "always skip the past cron point 
and wait for the
   next future one".
   
   **Backward compatibility:** The default is changed from `False` to `True` so 
that existing DAGs
   without an explicit `run_immediately` continue to run the most recent past 
cron point immediately,
   preserving the original behaviour of `CronTriggerTimetable`.
   
   **Changes:**
   - `_TriggerTimetable.next_dagrun_info`: on first run (`no prior runs`), 
always call
     `_calc_first_run()` regardless of `start_date`; after a pause/resume keep 
the existing
     "pick most recent past boundary" logic unchanged
   - `CronTriggerTimetable._calc_first_run`: simplified to three clean cases —
     `True` (run past), `False` (wait for next), `timedelta` (run past if 
within window)
   - Default `run_immediately` changed `False → True` in `CronTriggerTimetable`,
     `MultipleCronTriggerTimetable`, and `CronPartitionTimetable`
   - Docs: added full `run_immediately` documentation with examples and 
`versionadded:: 3.0.0`
   - Docs: corrected the paused-then-unpaused example (both timetables skip 
only Feb 1 and
     immediately trigger Feb 2 — the claim that `CronTriggerTimetable` skips 
Feb 2 as well was wrong)
   - Tests: updated existing tests and added 
`test_run_immediately_false_with_start_date`,
     `test_run_immediately_true_with_start_date`, 
`test_run_immediately_false_after_unpause`
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Sonnet 4.6
   
   


-- 
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