Mark only a run's most recent asset event as triggering it - #71441
Conversation
An asset event is linked to every dag run that consumed it, so a run that consumed several events showed "Triggered Dag Run" on each of them — in both the Asset Events view and a dag run's upstream asset events view — making it look as though more runs had been created than actually were. Only a run's most recent consumed event triggers it; the earlier ones are merely included in the run. Surfacing that distinction makes the attribution match what actually happened. closes: apache#56749
fcdb661 to
e6cd04e
Compare
56cc359 to
de82546
Compare
de82546 to
1273443
Compare
Address review feedback: match each created-dagrun reference to its source event by id instead of relying on the positional order of two parallel lists. The same asset event can trigger one dag run while being merely included in another (an asset can fan out to several consumers), so the flag is resolved per (event, run) pair. The endpoints always populate it, so it is a required field with no default. Also add a query-count assertion so both asset-event endpoints are guarded against an N+1 as the number of consumed events grows.
1273443 to
baf69b8
Compare
|
Just one CI failure we should resolve |
Backport failed to create: v3-3-test. View the failure log Run detailsNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
You can attempt to backport this manually by running: cherry_picker 3f66d0f v3-3-testThis should apply the commit to the v3-3-test branch and leave the commit in conflict state marking After you have resolved the conflicts, you can continue the backport process by running: cherry_picker --continueIf you don't have cherry-picker installed, see the installation guide. |
Backport failed to create: airflow-ctl/v0-1-test. View the failure log Run detailsNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
You can attempt to backport this manually by running: cherry_picker 3f66d0f airflow-ctl/v0-1-testThis should apply the commit to the airflow-ctl/v0-1-test branch and leave the commit in conflict state marking After you have resolved the conflicts, you can continue the backport process by running: cherry_picker --continueIf you don't have cherry-picker installed, see the installation guide. |
) * Mark only a run's most recent asset event as triggering it An asset event is linked to every dag run that consumed it, so a run that consumed several events showed "Triggered Dag Run" on each of them — in both the Asset Events view and a dag run's upstream asset events view — making it look as though more runs had been created than actually were. Only a run's most recent consumed event triggers it; the earlier ones are merely included in the run. Surfacing that distinction makes the attribution match what actually happened. closes: apache#56749 * Match asset event triggering by id and add an N+1 query-count test Address review feedback: match each created-dagrun reference to its source event by id instead of relying on the positional order of two parallel lists. The same asset event can trigger one dag run while being merely included in another (an asset can fan out to several consumers), so the flag is resolved per (event, run) pair. The endpoints always populate it, so it is a required field with no default. Also add a query-count assertion so both asset-event endpoints are guarded against an N+1 as the number of consumed events grows. * Small adjustments (cherry picked from commit 3f66d0f) # Conflicts: # airflow-core/src/airflow/api_fastapi/common/db/assets.py # airflow-core/src/airflow/ui/src/components/Assets/TriggeredRuns.tsx
…71547) * Mark only a run's most recent asset event as triggering it An asset event is linked to every dag run that consumed it, so a run that consumed several events showed "Triggered Dag Run" on each of them — in both the Asset Events view and a dag run's upstream asset events view — making it look as though more runs had been created than actually were. Only a run's most recent consumed event triggers it; the earlier ones are merely included in the run. Surfacing that distinction makes the attribution match what actually happened. closes: #56749 * Match asset event triggering by id and add an N+1 query-count test Address review feedback: match each created-dagrun reference to its source event by id instead of relying on the positional order of two parallel lists. The same asset event can trigger one dag run while being merely included in another (an asset can fan out to several consumers), so the flag is resolved per (event, run) pair. The endpoints always populate it, so it is a required field with no default. Also add a query-count assertion so both asset-event endpoints are guarded against an N+1 as the number of consumed events grows. * Small adjustments (cherry picked from commit 3f66d0f) # Conflicts: # airflow-core/src/airflow/api_fastapi/common/db/assets.py # airflow-core/src/airflow/ui/src/components/Assets/TriggeredRuns.tsx
) * Mark only a run's most recent asset event as triggering it An asset event is linked to every dag run that consumed it, so a run that consumed several events showed "Triggered Dag Run" on each of them — in both the Asset Events view and a dag run's upstream asset events view — making it look as though more runs had been created than actually were. Only a run's most recent consumed event triggers it; the earlier ones are merely included in the run. Surfacing that distinction makes the attribution match what actually happened. closes: apache#56749 * Match asset event triggering by id and add an N+1 query-count test Address review feedback: match each created-dagrun reference to its source event by id instead of relying on the positional order of two parallel lists. The same asset event can trigger one dag run while being merely included in another (an asset can fan out to several consumers), so the flag is resolved per (event, run) pair. The endpoints always populate it, so it is a required field with no default. Also add a query-count assertion so both asset-event endpoints are guarded against an N+1 as the number of consumed events grows. * Small adjustments



Fixes the misleading "Triggered Dag Run" attribution in the Asset Events view.
An asset event is linked to every dag run that consumed it, so when a run consumed several events the UI showed "Triggered Dag Run" on each of them — making it look as though more runs had been created than actually were. Now only a run's most recent consumed event is labelled "Triggered Dag Run"; the earlier consumed events are labelled "Included in Dag Run".
The
/assets/eventsendpoint flags the triggering event per run (ranking each run's consumed events by timestamp) and exposes it as atriggeringfield onDagRunAssetReference; the Asset Events UI renders the "triggered" and "included" groups accordingly.Scope: this covers the attribution/labelling half of the issue. The separate "older events silently ignored" scheduling behaviour was addressed by #62501 and is out of scope here.
closes: #56749
Screenshots (Asset Events view) — to attach
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 4.8) following the guidelines