Lee-W commented on code in PR #59724:
URL: https://github.com/apache/airflow/pull/59724#discussion_r2650626454


##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2277,6 +2253,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 | None,
+    ):
+        """
+        Conditionally update fields next_dagrun and next_dagrun_create_after 
on dag table.
+
+        If dag exceeds max active runs, set to None.
+
+        If dag's timetable not schedulable, don't update.
+
+        Otherwise, update via ``DagModel.calculate_dagrun_date_fields``.
+        """
+        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:
   I guess we're moving it here since we believe it's not going to happen. If 
not so, move it to above and exit early might be better



##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2277,6 +2253,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 | None,
+    ):
+        """
+        Conditionally update fields next_dagrun and next_dagrun_create_after 
on dag table.

Review Comment:
   nit: we use `dag` and `DAG` in the comments



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