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


##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2292,20 +2292,34 @@ def _create_dagruns_for_partitioned_asset_dags(self, 
session: Session) -> set[st
                 )
                 or 0
             )
+            # Distinct dag_ids across the *whole* backlog, not just this 
tick's oldest-cap
+            # slice (`pending_apdrs`) — a Dag whose partitions haven't reached 
the front of
+            # the FIFO queue yet would otherwise be missing from the log/audit 
row until its
+            # turn comes up. Same WHERE clause as the count query above so the 
two never drift.
+            backlog_dag_ids = set(
+                session.scalars(
+                    select(AssetPartitionDagRun.target_dag_id)
+                    .join(DagModel, DagModel.dag_id == 
AssetPartitionDagRun.target_dag_id)
+                    .where(
+                        AssetPartitionDagRun.created_dag_run_id.is_(None),
+                        DagModel.is_stale.is_(False),
+                    )
+                    .distinct()
+                )
+            )

Review Comment:
   Yep, sounds good, just merged them in to one PR. We can do the index part if 
this actually becomes an issue.



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