dstandish commented on code in PR #59724:
URL: https://github.com/apache/airflow/pull/59724#discussion_r2645748184
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2277,6 +2254,47 @@ def _schedule_dag_run(
return callback_to_run
+ def _update_next_dagrun_fields(
+ self,
+ *,
+ serdag: SerializedDAG,
+ dag_model: DagModel,
+ session: Session,
+ active_non_backfill_runs: int | None = None,
+ data_interval: DataInterval,
+ ):
+ """
+ Conditionally update fields next_dagrun and next_dagrun_create_after
on dag table.
+
+ If dag exceeds max active runs, don't update.
+
+ If dag's timetable not schedulable, don't update.
+
+ Otherwise, update.
+ """
+ exceeds_max, active_runs = self._exceeds_max_active_runs(
+ dag_model=dag_model,
+ active_non_backfill_runs=active_non_backfill_runs,
+ session=session,
+ )
+ if exceeds_max:
+ self.log.info(
+ "Dag exceeds max_active_runs; not creating any more runs",
+ dag_id=dag_model.dag_id,
+ active_runs=active_runs,
+ max_active_runs=dag_model.max_active_runs,
+ )
+ # null out next_dagrun_create_after so scheduler will not examine
this dag
+ # this is periodically reconsidered in the scheduler and dag
processor.
+ dag_model.next_dagrun_create_after = None
+ return
+
+ # If the DAG never schedules skip save runtime
+ if not serdag.timetable.can_be_scheduled:
+ return
Review Comment:
If it can't be scheduled, how did it even get here 🤯
--
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]