g-dailey opened a new issue, #60907:
URL: https://github.com/apache/airflow/issues/60907

   ### Apache Airflow version
   
   2.11.X
   
   ### If "Other Airflow 3 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   When filtering the DAG listing page by "Running" (either "All + Running" or 
"Active + Running"), the UI shows:
   - **Correct total count** in the header and pagination footer (e.g., "60 
DAGs")
   - **Incorrect/truncated list** of DAGs displayed (e.g., only ~20 DAGs 
visible)
   - **Next page button does not work** or shows empty/partial results
   
   The discrepancy occurs when DAGs have `max_active_runs > 1` and multiple 
concurrent DagRun instances are in the "running" state.
   
   ### What you think should happen instead?
   
   The DAG listing should display all DAGs matching the filter criteria, with 
pagination working correctly. The number of DAGs shown should match the count 
displayed in the header/footer.
   
   ### How to reproduce
   
   1. Create DAGs with `max_active_runs > 1` to allow concurrent running 
instances
   2. Create enough DAGs to trigger pagination (>25 with default page size)
   3. Trigger/schedule runs so multiple DagRuns per DAG are in "running" state
   4. Navigate to DAGs page in Airflow UI
   5. Select "All" + "Running" filter
   6. Observe: count shows correct total, but list shows fewer DAGs
   
   **Reproduction DAG file:**
   
   ```
   """
   DAG generator to reproduce pagination issue with Running filter.
   Creates 60 DAGs - some with multiple concurrent runs capability.
   """
   from datetime import datetime, timedelta
   from airflow import DAG
   from airflow.operators.bash import BashOperator
   
   TOTAL_DAGS = 60
   DAGS_WITH_MULTI_RUNS = 20
   
   default_args = {
       "owner": "test",
       "depends_on_past": False,
       "retries": 0,
   }
   
   def create_dag(dag_id: str, max_active_runs: int, sleep_duration: int):
       dag = DAG(
           dag_id=dag_id,
           default_args=default_args,
           description=f"Test DAG with max_active_runs={max_active_runs}",
           schedule_interval=timedelta(minutes=2),
           start_date=datetime(2026, 1, 20),
           catchup=True,
           max_active_runs=max_active_runs,
           is_paused_upon_creation=False,
           tags=["pagination-test", f"max-runs-{max_active_runs}"],
       )
   
       with dag:
           BashOperator(
               task_id="long_running_task",
               bash_command=f"echo 'Sleeping {sleep_duration}s' && sleep 
{sleep_duration}",
           )
       return dag
   
   # 40 DAGs with single active run
   for i in range(1, TOTAL_DAGS - DAGS_WITH_MULTI_RUNS + 1):
       dag_id = f"pagination_test_single_{i:03d}"
       globals()[dag_id] = create_dag(dag_id, max_active_runs=1, 
sleep_duration=600)
   
   # 20 DAGs with multiple active runs (these trigger the bug)
   for i in range(1, DAGS_WITH_MULTI_RUNS + 1):
       dag_id = f"pagination_test_multi_{i:03d}"
       globals()[dag_id] = create_dag(dag_id, max_active_runs=5, 
sleep_duration=900)
   ```
   
   
   
   
   
   
   ### Operating System
   
   Airflow docker image on Astro
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Astronomer
   
   ### Deployment details
   
   _No response_
   
   ### Anything else?
   
   The issue appears to be in the DAG listing view (airflow/www/views.py). When 
filtering by "Running" state:
   
   - Count query uses COUNT(DISTINCT dag_id) → returns correct count
   - List query joins DagModel with DagRun to filter by state
   - DAGs with multiple running DagRuns produce multiple rows in the join result
   - LIMIT/OFFSET pagination is applied before deduplication
   - Duplicate rows consume pagination slots, resulting in fewer unique DAGs 
displayed
   
   Example: If a DAG has 3 running DagRuns, it takes 3 "slots" in the LIMIT 25 
query, but only renders once in the UI.
   
   Similar issue has been reported in issue #53712 and #55017. 
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


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