KatalKavya96 opened a new pull request, #56089: URL: https://github.com/apache/airflow/pull/56089
### Problem - On the DAGs list, sorting by Last run currently uses last_run_start_date. Newly triggered runs that are Queued don’t have a start_date, so the row ordering is unstable: the DAG can sit low in the list (or off page 1) while queued, then jump to the top when the run transitions Queued → Running and start_date becomes non-NULL. This matches the issue report. ### Root cause - Sorting depends on start_date, which is only populated after a worker picks up the run. Queued runs lack start_date, but they do have run_after (the time they became eligible to run). ### What this PR changes - For the UI DAGs list endpoint, map the Last run sort key to: - MAX(COALESCE(DagRun.run_after, DagRun.start_date)) so queued runs participate in ordering immediately and the list remains stable through state transitions. - Keep the existing order_by contract used by the UI: order_by=start_date (and last_run_start_date, if sent) now resolve to the coalesced expression. No UI changes required. Preserve existing secondary ordering (e.g., by dag_id) where applicable, so pagination remains deterministic. ### User-visible effect - Descending (Latest → Earliest): the most recently triggered DAG (even if Queued) appears at/near the top immediately and does not jump when it starts running. - Ascending (Earliest → Latest): newly triggered DAGs move to the bottom immediately and stay during Queued → Running. With many DAGs (pagination), a DAG no longer disappears from page 1 simply because it is Queued. #56073 -- 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]
