ephraimbuddy commented on a change in pull request #18897:
URL: https://github.com/apache/airflow/pull/18897#discussion_r730902244
##########
File path: airflow/models/dag.py
##########
@@ -2425,6 +2425,14 @@ def bulk_write_to_db(cls, dags: Collection["DAG"],
session=None):
)
most_recent_runs = {run.dag_id: run for run in most_recent_runs_iter}
+ # Get number of active dagruns for all dags we are processing as a
single query.
+ num_active_runs = dict(
+ session.query(DagRun.dag_id, func.count('*'))
+ .filter(DagRun.dag_id.in_(existing_dag_ids),
DagRun.state.in_([State.RUNNING, State.QUEUED]))
+ .group_by(DagRun.dag_id)
+ .all()
+ )
Review comment:
Sounds good
--
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]