You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/09/02 09:35:39 UTC

[GitHub] [airflow] kaxil commented on a change in pull request #17945: Fix max_active_runs not allowing scheduling of other dagruns

kaxil commented on a change in pull request #17945:
URL: https://github.com/apache/airflow/pull/17945#discussion_r700918376



##########
File path: airflow/jobs/scheduler_job.py
##########
@@ -970,48 +971,61 @@ def _start_queued_dagruns(
         session: Session,
     ) -> int:
         """Find DagRuns in queued state and decide moving them to running state"""
-        dag_runs = self._get_next_dagruns_to_examine(State.QUEUED, session)
-
-        active_runs_of_dags = defaultdict(
-            lambda: 0,
-            session.query(DagRun.dag_id, func.count('*'))
-            .filter(  # We use `list` here because SQLA doesn't accept a set
-                # We use set to avoid duplicate dag_ids
-                DagRun.dag_id.in_(list({dr.dag_id for dr in dag_runs})),
-                DagRun.state == State.RUNNING,
-            )
-            .group_by(DagRun.dag_id)
-            .all(),
+        active_dags = (
+            session.query(DM)
+            .filter(DM.is_active == expression.true(), DM.is_paused == expression.false())

Review comment:
       Yeah that is mainly for MSSQL




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