jedcunningham commented on code in PR #27725:
URL: https://github.com/apache/airflow/pull/27725#discussion_r1026961840
##########
airflow/jobs/scheduler_job.py:
##########
@@ -774,25 +775,46 @@ def _execute(self) -> None:
@provide_session
def _update_dag_run_state_for_paused_dags(self, session: Session =
NEW_SESSION) -> None:
try:
- paused_dag_ids = DagModel.get_all_paused_dag_ids()
- for dag_id in paused_dag_ids:
- if dag_id in self._paused_dag_without_running_dagruns:
- continue
+ paused_dag_ids = {
+ paused_dag_id
+ for paused_dag_id, in session.query(DagModel.dag_id)
+ .join(DagRun.dag_model)
+ .filter(
+ DagModel.is_paused == expression.true(),
+ DagRun.state == DagRunState.RUNNING,
+ DagRun.run_type != DagRunType.BACKFILL_JOB,
+ )
+ .all()
+ }
- dag = SerializedDagModel.get_dag(dag_id)
- if dag is None:
- continue
+ for dag_id in paused_dag_ids:
Review Comment:
Found an old db with 27 million TIs, query is still fast 👍
--
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]