Skip to content

Allow filtering the Dags list by failed and success runs in any run state filter - #69875

Merged
pierrejeambrun merged 1 commit into
apache:mainfrom
yuseok89:feature/67094-any-run-state-filter-all-states
Jul 23, 2026
Merged

Allow filtering the Dags list by failed and success runs in any run state filter#69875
pierrejeambrun merged 1 commit into
apache:mainfrom
yuseok89:feature/67094-any-run-state-filter-all-states

Conversation

@yuseok89

@yuseok89 yuseok89 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Closes #67094

The Dags list has two run-state filters. "Last run state" matches on a Dag's latest run, and "Any run state" matches a Dag that has any run in the chosen state. The "Any run state" filter only offered queued and running, so a Dag with failed runs but a green latest run could not be found from the Dags list at all.
This adds failed and success to it, so both filters now cover all four states.

What changed

  • Backend (_AnyDagRunStateFilter). The filter now supports all four run states. Its query moved from dag_id IN (SELECT DISTINCT dag_id FROM dag_run WHERE state = X) to a correlated EXISTS, which the existing (dag_id, state) index resolves per Dag instead of scanning every run in the state. No new index is needed.
  • UI. The "Any run state" selector now lists the same four states as "Last run state".

Performance

Measured on a large dag_run table (a few million rows) across a few thousand Dags(Postgres), filtering by dag_run_state=success (the heaviest state):

  • Old DISTINCT scan of all matching runs: around a second or more
  • New correlated EXISTS: tens of milliseconds

The EXISTS cost grows only with Dag count (one index seek per Dag, stopping at the first match), not with run volume, so it stays fast well beyond typical Dag counts, and the gap widens further as run history grows.

Demo

Screen.Recording.2026-07-14.at.11.09.50.PM.mov

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)
    • Opus 4.8

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@boring-cyborg boring-cyborg Bot added area:API Airflow's REST/HTTP API area:UI Related to UI/UX. For Frontend Developers. labels Jul 14, 2026
@yuseok89
yuseok89 marked this pull request as ready for review July 14, 2026 16:08
@bbovenzi

Copy link
Copy Markdown
Contributor

I think this UX needs to be refined. I don't think any user would realistically search "any dag that has ever had a success", even "any dag that has ever had a failure" could quickly be useless for very old failures. I think we first need a time range filter for use cases like "dags with a failure in the last week", or "dags with any runs in the last 24 hours"

@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Jul 18, 2026
@yuseok89

Copy link
Copy Markdown
Contributor Author

@bbovenzi

Thanks for the review.
That makes sense to me. I think a time range is the right direction, so I prototyped two ways of adding it. A standalone time-range select in the filter bar could read as a page-wide filter, so both attach the time axis to the run-state filter itself.

Agreed that searching for "ever had a success" is unrealistic. I had added success for symmetry with "Last run state". With a time window attached though, something like "Dags with a successful run in the last 24 hours" does become meaningful.

Before the backend details, I'd like to settle the UI direction first. Two options:

Option A — attach a time window to the existing "Any run" filter

Screen.Recording.2026-07-19.at.2.27.01.PM.mov

When a state is selected, a within: segment appears joined to the same control(Last 24 hours / 7 days / 30 days / Any time). It defaults to Last 7 days, so the "very old failures" concern is addressed by the default behavior.

Option B — merge the two run-state filters into one

Screen.Recording.2026-07-19.at.2.40.08.PM.mov

Going a step further. Having "Last run state" and "Any run state" side by side is itself a bit confusing, so this merges them into a single Run state control with a scope (Latest run / Last 24 hours / 7 days / 30 days / Any time). Later, adding an "Any state" entry would cover "dags with any runs in the last 24 hours" with the same control.

My preference is B .
It removes the confusion of the two coexisting filters and covers both use cases you mentioned with one model. It does grow the scope of the change, though.
What do you think?

@bbovenzi

Copy link
Copy Markdown
Contributor

Yes, I prefer B too. Good idea

@bbovenzi bbovenzi modified the milestones: Airflow 3.4.0, Airflow 3.3.1 Jul 21, 2026

@pierrejeambrun pierrejeambrun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the current implementation, this is a net gain. (additional options to filter, while still leveraging indexes and keeping performance good)

I would merge this in the current form and follow up with a UX refactoring for those two filters in a second PR.

@pierrejeambrun

pierrejeambrun commented Jul 23, 2026

Copy link
Copy Markdown
Member

Discussed with Brent, let's merge this iteration which brings value. @yuseok89 please feel free to follow up with a new PR on the UX improvement suggested by Brent.

@pierrejeambrun
pierrejeambrun merged commit a990ce9 into apache:main Jul 23, 2026
189 checks passed
@yuseok89

Copy link
Copy Markdown
Contributor Author

@pierrejeambrun
Sounds good, thanks! I'll open a follow-up PR for the unified filter.

pierrejeambrun pushed a commit to astronomer/airflow that referenced this pull request Jul 23, 2026
henry3260 pushed a commit that referenced this pull request Jul 23, 2026
…tate filter (#69875) (#70293)

(cherry picked from commit a990ce9)

Co-authored-by: Yuseok Jo <yuseok89@gmail.com>
vatsrahul1001 pushed a commit that referenced this pull request Aug 5, 2026
…tate filter (#69875) (#70293)

(cherry picked from commit a990ce9)

Co-authored-by: Yuseok Jo <yuseok89@gmail.com>
dabla pushed a commit to dabla/airflow that referenced this pull request Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:UI Related to UI/UX. For Frontend Developers. ready for maintainer review Set after triaging when all criteria pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DAG list: state filters should use DAG run counts by state (like 2.x), not latest-run state only

4 participants