Skip to content

Render Grid and Graph when a path leaves and re-enters a TaskGroup - #73933

Closed
JH0917 wants to merge 1 commit into
apache:mainfrom
JH0917:tolerate-taskgroup-cycles-in-graph
Closed

JH0917 wants to merge 1 commit into
apache:mainfrom
JH0917:tolerate-taskgroup-cycles-in-graph

Conversation

@JH0917

@JH0917 JH0917 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Since 3.3.1 (#69933), Grid and Graph return HTTP 500 when TaskGroups wait on each other as
units, even though the task graph is acyclic. A path that leaves a group and re-enters it
(g.a >> ext >> g.b) is enough, and partial_subset filtering can create the same shape
(reported in the #73678 discussion), so the UI sort must tolerate it.

Changes:

  1. When all remaining children are blocked, pass numbering releases one child on the cycle
    and continues. The sweep path falls back to pass numbering instead of raising.
  2. Dags without a group-level cycle are sorted exactly as before. The task-sdk sort still raises.

Relation to #73724: both address the same bug with different approaches. That PR collapses
each SCC into one unit, which keeps the members of a cycle together. This PR breaks the cycle at
a single child inside the existing pass-numbering loop, which keeps the remaining dependencies in
order (for a ring of three groups, one dependency ends up out of order instead of two).

Benchmark and randomized check

Root-level topological_sort, best of 3:

Dag shape children this PR #73724
acyclic chain 10,000 5.6 ms 5.6 ms
5,000 g.a >> bridge >> g.b cycles 10,000 22.2 ms 24.2 ms
reverse-declared chain behind one cycle 10,002 13.2 ms 20.8 ms
5,000-task chain behind 2,000 cycles 9,000 37.3 ms 20.8 ms

3,000 random Dags: groups without a group-level cycle (11,504) sort identically to main;
in groups with one (2,061), out-of-order dependencies total 3,882 vs 4,618.

related: #73678


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5.5)

Generated-by: Claude Code (Opus 5.5) following the guidelines

@boring-cyborg boring-cyborg Bot added area:API Airflow's REST/HTTP API area:DAG-processing labels Sep 30, 2026
@JH0917 JH0917 changed the title Fix Grid and Graph 500 errors for TaskGroup-level cycles Break TaskGroup-level cycles at one child in the Grid/Graph sort Sep 30, 2026
@JH0917
JH0917 force-pushed the tolerate-taskgroup-cycles-in-graph branch from ec28e20 to 3491318 Compare September 30, 2026 04:08
@JH0917 JH0917 changed the title Break TaskGroup-level cycles at one child in the Grid/Graph sort Render Grid and Graph when a path leaves and re-enters a TaskGroup Sep 30, 2026
@fat-catTW

fat-catTW commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for working on this.
But I’m concerned that the current fallback may produce a misleading order beyond just breaking one edge in the group-level cycle.

In the new test case:

extract >> staging >> spark_job >> mart >> publish

the real task path is:

extract -> models.staging -> spark_job -> models.mart -> publish

But the expected root-level order is:

extract, models, publish, spark_job

That puts publish before spark_job, even though every real task path to publish goes through spark_job.

This seems potentially confusing for users because the UI may suggest that downstream work outside the cycle can happen before a task it actually depends on. More generally, since a collapsed TaskGroup can only appear once, a path like models.staging -> spark_job -> models.mart cannot be faithfully represented as models -> spark_job -> models, so the fallback can make the group look like a single execution unit before or after spark_job, even though only part of the group is before it.

Is this tradeoff intentional?

@kaxil

kaxil commented Oct 1, 2026

Copy link
Copy Markdown
Member

Closing this. #73724 is already open for #73678, from the maintainer who filed the issue and said they would handle it, five days before this one. This PR also encodes an order that contradicts the Dag: the new test builds extract >> staging >> spark_job >> mart >> publish and expects ["extract", "models", "publish", "spark_job"], which puts publish before spark_job even though every path to publish runs through spark_job.

@kaxil kaxil closed this Oct 1, 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:DAG-processing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants