Skip to content

Describe loop reruns and expansion size in OpenLineage events - #75133

Closed
kacpermuda wants to merge 8 commits into
apache:mainfrom
kacpermuda:ol-loop-execution-details
Closed

kacpermuda wants to merge 8 commits into
apache:mainfrom
kacpermuda:ol-loop-execution-details

Conversation

@kacpermuda

Copy link
Copy Markdown
Collaborator

Follow-up to #74752 and #75132, and stacked on both: only the last commit (Describe loop reruns and expansion size in OpenLineage task events) is new here.

With #75132, OpenLineage events can carry everything needed to trace a task execution back from a single event, without reading the Airflow database:

  • taskInstance.loop groups the loop details: group_id, index, max_iterations, plus the loop region_id, trajectory, forked_from_region_id and resumes_from_index (which rerun of the loop an event comes from and what it replaced), and the gate's decision. This replaces the flat loop_* fields added in Fix task loop information and tests for OpenLineage provider #74752, which haven't been released, so the loop details can later describe enclosing loops too.
  • taskInstance.expanded_ti_count: how many instances a mapped task's expansion has, so consumers know how many events to expect.
  • Worker events read the new public RuntimeTaskInstance attributes. Events for manual state changes get the same details from get_task_instance_execution_position instead of querying dynamic_region. Airflow 3.4 pre-releases without these fall back to what Fix task loop information and tests for OpenLineage provider #74752 does.
  • A new guide documents how to identify a task execution from an event: run ids, every field, how each kind of task emits events, and grouping keys.

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

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


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

🤖 Generated with Claude Code

kacpermuda and others added 8 commits October 19, 2026 19:51
…ners

A single event about a task instance should be enough to tell which execution it
describes: which loop pass and rerun of the loop it ran in, how many instances its
mapped expansion has, and why a loop gate stopped. Workers only had the loop
iteration, a mapped task inside a loop could not be tied to the pass it ran in,
reruns could only be ordered by comparing region ids from two events, and server
side consumers such as listeners had to read region rows to place a stored task
instance.

Co-Authored-By: Claude <noreply@anthropic.com>
Provider mypy and the docs spellcheck run in CI through breeze rather than
the default prek hooks, so they were not caught locally before the previous push.

Co-Authored-By: Claude <noreply@anthropic.com>
Alerting on why a loop stopped (for example, its until condition still being false at
max_iterations) needs the gate's decision in the event itself, without reading the Airflow
metadata database.

Co-Authored-By: Claude <noreply@anthropic.com>
The run id must not depend on the optional loop iteration, and the lineage macro should
place a task instance the same way the listener does.

Co-Authored-By: Claude <noreply@anthropic.com>
A region of an unexpected shape, or a failed lookup of a mapped task's iteration, must not
merge the runs of loop iterations or cost an event. Tests now pin the region shapes Airflow
creates, so a change to them fails the provider's tests instead of silently changing events.

Co-Authored-By: Claude <noreply@anthropic.com>
The dbt Cloud and Dataproc tests patched how OpenLineage builds a task's run id, so they broke
when that changed. Stubbing the macros they actually use keeps them independent of it.

Co-Authored-By: Claude <noreply@anthropic.com>
Alerting on task loops and mapped tasks has to work from one event at a time:
telling which pass and which rerun of a loop an event comes from, whether that
rerun superseded an earlier one, and how many mapped instances to expect. Loop
details are grouped in one object so that it can describe enclosing loops if
Airflow ever nests them, and manual state changes now get the same details from
Airflow as worker events instead of reading its region tables.

Co-Authored-By: Claude <noreply@anthropic.com>
@kacpermuda

Copy link
Copy Markdown
Collaborator Author

Closed in favor of #74752 as the core PR was merged before the OL, so we can just do it all in single OL PR

@kacpermuda kacpermuda closed this Oct 21, 2026
@kacpermuda
kacpermuda deleted the ol-loop-execution-details branch October 21, 2026 11:45
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.

1 participant