nailo2c commented on code in PR #58543:
URL: https://github.com/apache/airflow/pull/58543#discussion_r3156561600
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2264,6 +2266,63 @@ def _update_state(dag: SerializedDAG, dag_run: DagRun):
dag_run.run_id,
)
continue
+ # For AssetAndTimeSchedule, defer starting until all required
assets are queued.
+ # Only gate scheduled runs; manual and backfill runs should start
immediately.
+ if isinstance(dag.timetable, AssetAndTimeSchedule) and
dag_run.run_type == DagRunType.SCHEDULED:
+ # Reuse dagrun_timeout to fail runs that wait in QUEUED for
assets for too long.
+ if (
+ dag.dagrun_timeout
+ and dag_run.queued_at
+ and dag_run.queued_at < timezone.utcnow() -
dag.dagrun_timeout
+ ):
+ dag_run.set_state(DagRunState.FAILED)
+ session.flush()
+ self.log.info(
+ "Run %s of %s has timed-out while waiting for assets",
+ dag_run.run_id,
+ dag_run.dag_id,
+ )
+ if (
+ dag_run.run_type
+ in (
+ DagRunType.SCHEDULED,
+ DagRunType.MANUAL,
+ DagRunType.ASSET_TRIGGERED,
+ )
+ and dag_run.dag_model is not None
+ ):
+
self._set_exceeds_max_active_runs(dag_model=dag_run.dag_model, session=session)
Review Comment:
I think it's still necessary. Once the queued run fails, we need to update
`dag_model.exceeds_max_non_backfill`. Otherwise Scheduler may still think the
Dag is maxed out and skip creating the next scheduled run.
https://github.com/apache/airflow/blob/b3138e2400eeed96863c9ced3ff2ff3e0ad7a519/airflow-core/src/airflow/jobs/scheduler_job_runner.py#L3314
--
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]