You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "bluek1te (via GitHub)" <gi...@apache.org> on 2023/02/28 16:00:23 UTC

[GitHub] [airflow] bluek1te commented on issue #27399: CronTriggerTimetable lost one task occasionally

bluek1te commented on issue #27399:
URL: https://github.com/apache/airflow/issues/27399#issuecomment-1448436386

   Hello friends. Thinking about @Gollum999's explanation of the problem case, I ended up being able to fix the missed run issue by doing this:
   
   ```diff
   diff --git a/airflow/timetables/trigger.py b/airflow/timetables/trigger.py
   index 86ab58cc4d..67dd239f89 100644
   --- a/airflow/timetables/trigger.py
   +++ b/airflow/timetables/trigger.py
   @@ -93,7 +93,8 @@ class CronTriggerTimetable(CronMixin, Timetable):
                if restriction.earliest is not None and current_time < restriction.earliest:
                    next_start_time = self._align_to_next(restriction.earliest)
                else:
   -                next_start_time = self._align_to_next(current_time)
   +                prev_start_time = self._align_to_prev(current_time)
   +                next_start_time = self._align_to_next(prev_start_time)
            if restriction.latest is not None and restriction.latest < next_start_time:
                return None
            return DagRunInfo.interval(next_start_time - self._interval, next_start_time)
   ```
   Instead of aligning next with the current time and running into the race condition with the scheduler, it might be better if we align next to the previously scheduled time.
   I would like to open this up to a formal PR if y'all think this is sufficient. Thoughts?


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org