kaxil commented on code in PR #73693:
URL: https://github.com/apache/airflow/pull/73693#discussion_r4109594145


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/dags.py:
##########
@@ -274,9 +274,20 @@ def get_dag_details(
         or 0
     )
 
-    # Add is_favorite and active_runs_count fields to the Dag model
+    # Count queued Dag runs: these are waiting for an active run to finish 
before they can start.
+    queued_runs_count = (
+        session.scalar(
+            select(func.count())
+            .select_from(DagRun)
+            .where(DagRun.dag_id == dag_id, DagRun.state == DagRunState.QUEUED)

Review Comment:
   This counts queued backfill runs too, and those aren't waiting on the Dag's 
`max_active_runs`. The scheduler groups running runs by `(dag_id, backfill_id)` 
and gates backfill runs on `Backfill.max_active_runs` instead 
(`get_queued_dag_runs_to_set_running` and `_start_queued_dagruns`). A backfill 
creates all of its runs as QUEUED up front, so a 100-date backfill on a 
`max_active_runs=16` Dag would render `10 of 16 (90 queued)` with a tooltip 
pointing at the Dag's limit. Should this filter on 
`DagRun.backfill_id.is_(None)`? The same applies to `active_runs_count` just 
above, which is how `X of Y` can already exceed `Y` on main when the backfill's 
`max_active_runs` (default 10) is higher than the Dag's.



##########
airflow-core/src/airflow/ui/src/pages/Dag/Header.tsx:
##########
@@ -113,11 +114,27 @@ export const Header = ({
     },
     ...nextRunStat,
     {
-      label: translate("dagDetails.activeRuns"),
+      label:
+        (dag?.queued_runs_count ?? 0) > 0 ? (

Review Comment:
   The icon keys off `queued_runs_count > 0` alone, but the tooltip says the 
runs are waiting for an active run to complete. That isn't true for a paused 
Dag: a run triggered while paused sits in QUEUED and 
`get_queued_dag_runs_to_set_running` skips paused Dags, so the header shows `0 
of 16 (1 queued)` plus a tooltip about an active run finishing. Same for the 
short window ashb mentioned where the scheduler just hasn't picked the run up 
yet. What about keeping the `(N queued)` text whenever it's non-zero, but only 
showing the icon when `active_runs_count >= max_active_runs && !is_paused`?



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