ashb commented on a change in pull request #16358:
URL: https://github.com/apache/airflow/pull/16358#discussion_r649077543



##########
File path: airflow/jobs/scheduler_job.py
##########
@@ -1593,7 +1592,9 @@ def _create_dag_runs(self, dag_models: 
Iterable[DagModel], session: Session) ->
             # we need to run self._update_dag_next_dagruns if the Dag Run 
already exists or if we
             # create a new one. This is so that in the next Scheduling loop we 
try to create new runs
             # instead of falling in a loop of Integrity Error.
-            if (dag.dag_id, dag_model.next_dagrun) not in active_dagruns:
+            if (dag.dag_id, dag_model.next_dagrun) not in active_dagruns and 
len(
+                active_dagruns
+            ) < dag.max_active_runs:

Review comment:
       Two things:
   
   1) This variable is badly named, and the "active" prefix is incorrect -- it 
turns out it is just _all_ dagruns, not just active/running ones
   2) len(active_dagruns) includes all dags, not just the current `dag.dag_id`
   
   so this check needs changing.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to