Skip to content

Give every mapped expansion a region and store its index as region_index - #74346

Merged
ashb merged 1 commit into
task-loops-stack-4from
task-loops-stack-5
Oct 10, 2026
Merged

ashb merged 1 commit into
task-loops-stack-4from
task-loops-stack-5

Conversation

@ashb

@ashb ashb commented Oct 6, 2026

Copy link
Copy Markdown
Member

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

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

Comment thread airflow-core/src/airflow/models/dagrun.py
Comment thread airflow-core/src/airflow/models/dagrun.py Outdated
Comment thread airflow-core/src/airflow/models/dagrun.py
Comment thread airflow-core/src/airflow/ti_deps/dep_context.py Outdated
Comment thread airflow-core/src/airflow/serialization/definitions/xcom_arg.py
Comment thread airflow-core/src/airflow/jobs/scheduler_job_runner.py
Comment thread airflow-core/src/airflow/models/taskinstance.py Outdated
Comment thread airflow-core/tests/unit/cli/commands/test_task_command.py
Comment thread airflow-core/tests/unit/models/test_mappedoperator.py Outdated
Comment thread airflow-core/tests/unit/ti_deps/deps/test_trigger_rule_dep.py Outdated
@ashb
ashb force-pushed the task-loops-stack-5 branch from 8c43b91 to 91d8983 Compare October 7, 2026 13:57
@ashb
ashb removed this pull request from stack #74339 October 7, 2026 15:20
@ashb
ashb force-pushed the task-loops-stack-5 branch from 91d8983 to d3f9ca7 Compare October 7, 2026 15:22
@ashb
ashb added this pull request to stack #74410 October 7, 2026 15:22
@ashb
ashb force-pushed the task-loops-stack-5 branch from d3f9ca7 to 5201df1 Compare October 7, 2026 20:57
@ashb
ashb force-pushed the task-loops-stack-5 branch 2 times, most recently from 85bbef2 to 63cb154 Compare October 8, 2026 13:53
@ashb
ashb marked this pull request as ready for review October 8, 2026 13:58
Comment thread airflow-core/src/airflow/models/dagrun.py Outdated
Comment thread airflow-core/src/airflow/models/dagrun.py
Comment thread airflow-core/src/airflow/models/task_coordinates.py
Comment thread airflow-core/src/airflow/models/taskinstance.py Outdated
Comment thread airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_xcoms.py Outdated
@ashb
ashb force-pushed the task-loops-stack-5 branch 2 times, most recently from 5149013 to 93f88c1 Compare October 9, 2026 10:32
@ashb
ashb force-pushed the task-loops-stack-5 branch from 93f88c1 to 31f60f7 Compare October 9, 2026 14:03
@ashb
ashb force-pushed the task-loops-stack-5 branch 2 times, most recently from ba7075e to 38853b7 Compare October 9, 2026 20:34
@ashb
ashb force-pushed the task-loops-stack-5 branch 2 times, most recently from 685c2a1 to 9f0a1c6 Compare October 9, 2026 22:18
@ashb
ashb force-pushed the task-loops-stack-5 branch from 9f0a1c6 to 930f347 Compare October 10, 2026 07:05
Mapped tasks were the one kind of dynamic work still outside the region
model: their instances sat in the sentinel region and were told apart only by
map_index. A loop has to be able to contain an expansion, one per pass, and that
only works if the expansion owns a region of its own.

The coordinate column is renamed in place so large deployments pay for metadata
changes, not a table rewrite. No table is rebuilt because SQLite's rebuild would
cascade-delete the rows that reference task_instance.id. legacy_task_data_owner,
xcom_v1 and rtif_v1 keep map_index because they record the coordinates their
rows had before regions existed. The ORM keeps map_index as an alias: Jinja
log-filename templates and provider code still read ti.map_index from ORM rows,
and removing it needs its own audit.

Mapping keeps its existing behaviour. A task's region is born with its
placeholder, re-expansion grows or shrinks it in place, and a map never forks.
Promoting the placeholder to index 0 stays in place too. Attempts retired before
the promotion stay at index -1: they own their XCom, rendered fields and log
files by UUID, and moving them could collide with retired attempts already
at index 0. A pre-region placeholder never ran, so it has no history to keep;
it moves into a freshly minted region and is promoted like any other, instead
of being retired as a phantom failed try. Pre-region expansions stay in the
sentinel region and keep revising in place, so the upgrade does not rewrite
existing rows.

Callers that address a task instance by public coordinates now find a task's own
region as well as the sentinel. The DagRun wait endpoint reads current producers
only and rejects loop results, because which pass's result to return would be
ambiguous.
@ashb
ashb force-pushed the task-loops-stack-5 branch from 30857fb to 256ed4b Compare October 10, 2026 16:18
@ashb
ashb merged commit 93f857f into main Oct 10, 2026
219 of 234 checks passed
@ashb
ashb deleted the task-loops-stack-5 branch October 10, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants