uranusjr commented on code in PR #71072:
URL: https://github.com/apache/airflow/pull/71072#discussion_r3732967216


##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2247,13 +2256,55 @@ def _create_dagruns_for_partitioned_asset_dags(self, 
session: Session) -> set[st
                     DagModel.is_stale.is_(False),
                 )
                 .order_by(AssetPartitionDagRun.created_at, 
AssetPartitionDagRun.id)
-                .limit(self._max_partition_dag_runs_per_loop),
+                .limit(self._max_partition_dag_runs_per_loop + 1),
                 of=AssetPartitionDagRun,
                 skip_locked=True,
                 key_share=False,
                 session=session,
             )
         ).all()
+        has_backlog = len(rows) > self._max_partition_dag_runs_per_loop
+        pending_apdrs = rows[: self._max_partition_dag_runs_per_loop]
+        if has_backlog:
+            self.log.warning(
+                "Reached the per-tick cap on pending partitioned Dag runs; the 
remaining backlog "
+                "will be evaluated over subsequent scheduler ticks",
+                cap=self._max_partition_dag_runs_per_loop,
+                pending_count=len(pending_apdrs),

Review Comment:
   Also, if row count if a problem, we should add an index on APDR to prevent 
table scan.



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