Consume all mapped asset events on the next triggered run - #71996
Open
Vamsi-klu wants to merge 3 commits into
Open
Consume all mapped asset events on the next triggered run#71996Vamsi-klu wants to merge 3 commits into
Vamsi-klu wants to merge 3 commits into
Conversation
The scheduler already attaches every queued mapped outlet event, but the suite never drove that through TaskInstance.register_asset_changes_in_db. Without that fixture the original mapped-outlet miss can come back unnoticed. Co-authored-by: Cursor <cursoragent@cursor.com>
The leftover case never checked that events 1 and 2 were already queued before the second tick, so a fourth-event rescue would still pass. Failed-index and OR cases had the same hole: they never marked a failed TI or left a second asset's ADRQ in place. Co-authored-by: Cursor <cursoragent@cursor.com>
apache#54659 is only closed if the consumer task sees every mapped event in template context, not just consumed_asset_events on the DagRun. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
cc @uranusjr @ashb @XD-DENG mapped outlet consume-all coverage on the scheduler path. Drafted-by: Cursor Grok 4.6; reviewed by @Vamsi-klu before posting |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consume all mapped asset events on the next triggered run
closes: #54659
What I did
Tests only. Mapped producer
@task(outlets=[asset]).expand(...)succeeds, then a scheduler tick. Assert all N events land on the consumer run and intriggering_asset_events. Also pins empty expand, a failed map index, leftovers on the next tick, AND/OR schedules, alias yields, catchup, and two producers in the same second. No production change. No newsfragment.Why I did
Three mapped outlets were finishing together and the consumer only saw a subset in
triggering_asset_events. Consume-by-event-id is already on main. Existing tests still insert ADRQ by hand, so they never covered this emit path. These tests also drive onedag_maker.run_tipath.How I did
Emit:
register_asset_changes_in_dbafter mapped SUCCESS, plus onedag_maker.run_ti(..., map_index=N)case.Consume:
SchedulerJobRunner._create_dagruns_for_dags.Context:
get_template_contextafter loadingconsumed_asset_events.AND waits for the second asset, then consumes the leftover queue. One tick batches all visible events. That is the default, not a bug. Leftovers stay for the next tick.
What's the impact
None at runtime. If consume-by-id or the mapped emit path regresses, these tests fail instead of silently dropping events.
What's the testing
airflow-core/tests/unit/jobs/test_scheduler_job.pytest_mapped_asset_empty_expand_creates_no_runtest_mapped_asset_events_consumed_togethertest_mapped_asset_run_ti_consumes_all_outletstest_mapped_asset_leftovers_consumed_on_next_ticktest_mapped_asset_failed_index_not_queuedtest_mapped_asset_two_producers_same_secondtest_mapped_asset_alias_yields_consumed_togethertest_mapped_asset_and_condition_keeps_adrqtest_mapped_asset_or_condition_consumes_fan_outtest_mapped_asset_catchup_keeps_queued_eventsWas generative AI tooling used to co-author this PR?
Generated-by: Grok 4.6 following the guidelines