Repository navigation
Keep mapped tasks when clearing with run on latest version - #76420
Merged
vatsrahul1001 merged 3 commits intoNov 4, 2026
Merged
vatsrahul1001 merged 3 commits into
vatsrahul1001 merged 3 commits into
Conversation
uranusjr
reviewed
Nov 4, 2026
uranusjr
reviewed
Nov 4, 2026
uranusjr
reviewed
Nov 4, 2026
ephraimbuddy
force-pushed
the
keep-mapped-tis-when-clearing-on-latest-version
branch
2 times, most recently
from
November 4, 2026 12:45
448bc29 to
07b3561
Compare
uranusjr
approved these changes
Nov 4, 2026
Member
|
The last comment and the one on regression above can be done in a follow-up. |
This was referenced Nov 4, 2026
Clearing on the latest Dag version re-checks the run's task instances against that version. When the producer of a mapped task's input is cleared in the same request, its new attempt has no XCom yet, so the mapped length cannot be resolved and every expanded instance was marked removed. Nothing expands a removed index again, so the mapped task never re-ran and its downstream tasks ran as if it had finished. The same happened when a new version switched a task from literal to XCom mapping before the producer had run. The scheduler already trims or extends a mapped task once its upstreams have finished, so keeping the instances lets it settle the count from the producer's new value.
The removal is not limited to clearing with "run on latest version". For a run without a bundle version, the scheduler checks the run's integrity whenever the Dag's structure changes, and before the fix that check removed the mapped instances of a cleared producer that had not run again yet.
…rsion A mapped index removed earlier, by a shrink or because the task left the Dag, stayed removed after a clear on the latest version re-ran its producer: the unresolved-count branch skipped the restore block, and _revise_map_indexes_if_mapped never brings a removed index back.
vatsrahul1001
force-pushed
the
keep-mapped-tis-when-clearing-on-latest-version
branch
from
November 4, 2026 14:45
07b3561 to
d10f7bc
Compare
vatsrahul1001
deleted the
keep-mapped-tis-when-clearing-on-latest-version
branch
November 4, 2026 16:27
Contributor
Backport successfully created: v3-4-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
vatsrahul1001
pushed a commit
that referenced
this pull request
Nov 4, 2026
#76420) (#76468) * Keep mapped tasks when clearing with run on latest version Clearing on the latest Dag version re-checks the run's task instances against that version. When the producer of a mapped task's input is cleared in the same request, its new attempt has no XCom yet, so the mapped length cannot be resolved and every expanded instance was marked removed. Nothing expands a removed index again, so the mapped task never re-ran and its downstream tasks ran as if it had finished. The same happened when a new version switched a task from literal to XCom mapping before the producer had run. The scheduler already trims or extends a mapped task once its upstreams have finished, so keeping the instances lets it settle the count from the producer's new value. * Test that the scheduler keeps cleared mapped tasks on Dag change The removal is not limited to clearing with "run on latest version". For a run without a bundle version, the scheduler checks the run's integrity whenever the Dag's structure changes, and before the fix that check removed the mapped instances of a cleared producer that had not run again yet. * Restore removed mapped tasks when their producer re-runs on latest version A mapped index removed earlier, by a shrink or because the task left the Dag, stayed removed after a clear on the latest version re-ran its producer: the unresolved-count branch skipped the restore block, and _revise_map_indexes_if_mapped never brings a removed index back. (cherry picked from commit cd3ae40) Co-authored-by: Ephraim Anierobi <splendidzigy24@gmail.com>
github-actions Bot
pushed a commit
to aws-mwaa/upstream-to-airflow
that referenced
this pull request
Nov 4, 2026
apache#76420) * Keep mapped tasks when clearing with run on latest version Clearing on the latest Dag version re-checks the run's task instances against that version. When the producer of a mapped task's input is cleared in the same request, its new attempt has no XCom yet, so the mapped length cannot be resolved and every expanded instance was marked removed. Nothing expands a removed index again, so the mapped task never re-ran and its downstream tasks ran as if it had finished. The same happened when a new version switched a task from literal to XCom mapping before the producer had run. The scheduler already trims or extends a mapped task once its upstreams have finished, so keeping the instances lets it settle the count from the producer's new value. * Test that the scheduler keeps cleared mapped tasks on Dag change The removal is not limited to clearing with "run on latest version". For a run without a bundle version, the scheduler checks the run's integrity whenever the Dag's structure changes, and before the fix that check removed the mapped instances of a cleared producer that had not run again yet. * Restore removed mapped tasks when their producer re-runs on latest version A mapped index removed earlier, by a shrink or because the task left the Dag, stayed removed after a clear on the latest version re-ran its producer: the unresolved-count branch skipped the restore block, and _revise_map_indexes_if_mapped never brings a removed index back. (cherry picked from commit cd3ae40) Co-authored-by: Ephraim Anierobi <splendidzigy24@gmail.com>
vatsrahul1001
pushed a commit
that referenced
this pull request
Nov 4, 2026
#76420) (#76468) * Keep mapped tasks when clearing with run on latest version Clearing on the latest Dag version re-checks the run's task instances against that version. When the producer of a mapped task's input is cleared in the same request, its new attempt has no XCom yet, so the mapped length cannot be resolved and every expanded instance was marked removed. Nothing expands a removed index again, so the mapped task never re-ran and its downstream tasks ran as if it had finished. The same happened when a new version switched a task from literal to XCom mapping before the producer had run. The scheduler already trims or extends a mapped task once its upstreams have finished, so keeping the instances lets it settle the count from the producer's new value. * Test that the scheduler keeps cleared mapped tasks on Dag change The removal is not limited to clearing with "run on latest version". For a run without a bundle version, the scheduler checks the run's integrity whenever the Dag's structure changes, and before the fix that check removed the mapped instances of a cleared producer that had not run again yet. * Restore removed mapped tasks when their producer re-runs on latest version A mapped index removed earlier, by a shrink or because the task left the Dag, stayed removed after a clear on the latest version re-ran its producer: the unresolved-count branch skipped the restore block, and _revise_map_indexes_if_mapped never brings a removed index back. (cherry picked from commit cd3ae40) Co-authored-by: Ephraim Anierobi <splendidzigy24@gmail.com>
vatsrahul1001
pushed a commit
that referenced
this pull request
Nov 4, 2026
#76420) (#76468) * Keep mapped tasks when clearing with run on latest version Clearing on the latest Dag version re-checks the run's task instances against that version. When the producer of a mapped task's input is cleared in the same request, its new attempt has no XCom yet, so the mapped length cannot be resolved and every expanded instance was marked removed. Nothing expands a removed index again, so the mapped task never re-ran and its downstream tasks ran as if it had finished. The same happened when a new version switched a task from literal to XCom mapping before the producer had run. The scheduler already trims or extends a mapped task once its upstreams have finished, so keeping the instances lets it settle the count from the producer's new value. * Test that the scheduler keeps cleared mapped tasks on Dag change The removal is not limited to clearing with "run on latest version". For a run without a bundle version, the scheduler checks the run's integrity whenever the Dag's structure changes, and before the fix that check removed the mapped instances of a cleared producer that had not run again yet. * Restore removed mapped tasks when their producer re-runs on latest version A mapped index removed earlier, by a shrink or because the task left the Dag, stayed removed after a clear on the latest version re-ran its producer: the unresolved-count branch skipped the restore block, and _revise_map_indexes_if_mapped never brings a removed index back. (cherry picked from commit cd3ae40) Co-authored-by: Ephraim Anierobi <splendidzigy24@gmail.com>
vatsrahul1001
pushed a commit
that referenced
this pull request
Nov 4, 2026
#76420) (#76468) * Keep mapped tasks when clearing with run on latest version Clearing on the latest Dag version re-checks the run's task instances against that version. When the producer of a mapped task's input is cleared in the same request, its new attempt has no XCom yet, so the mapped length cannot be resolved and every expanded instance was marked removed. Nothing expands a removed index again, so the mapped task never re-ran and its downstream tasks ran as if it had finished. The same happened when a new version switched a task from literal to XCom mapping before the producer had run. The scheduler already trims or extends a mapped task once its upstreams have finished, so keeping the instances lets it settle the count from the producer's new value. * Test that the scheduler keeps cleared mapped tasks on Dag change The removal is not limited to clearing with "run on latest version". For a run without a bundle version, the scheduler checks the run's integrity whenever the Dag's structure changes, and before the fix that check removed the mapped instances of a cleared producer that had not run again yet. * Restore removed mapped tasks when their producer re-runs on latest version A mapped index removed earlier, by a shrink or because the task left the Dag, stayed removed after a clear on the latest version re-ran its producer: the unresolved-count branch skipped the restore block, and _revise_map_indexes_if_mapped never brings a removed index back. (cherry picked from commit cd3ae40) Co-authored-by: Ephraim Anierobi <splendidzigy24@gmail.com>
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.
Clearing a Dag run with "run on latest version" marked every instance of a mapped task
removedwhen the producer of its input was cleared in the same request. They stayedremovedafter the producer ran again, so the mapped task never re-ran and its downstream tasks ran as if it had finished.Clearing on the latest version calls
verify_integrity, which re-checks the mapped task's length. Since #74222 that length is read from the producer's current attempt, and a cleared producer's new attempt has no XCom yet. The check then took the branch that removes every expanded instance when the mapping can't be resolved. Nothing expands a removed index again:_revise_map_indexes_if_mappedonly revises schedulable instances and doesn't recreate removed indexes, and nomap_index=-1placeholder is left to expand. #71425 later made the same check run for running and queued runs as well.The expanded instances are now kept while the mapping can't be resolved. The scheduler already trims or extends them once the upstreams finish, as it did before #74222, when the length could still be read from the producer's previous run.
Changed existing test:
test_mapped_literal_to_xcom_arg_verify_integrityasserted that switching a task from literal to XCom mapping, before the producer has run, removes all of its instances. Those instances were never expanded again either, so the task never ran under its new mapping. The test now checks that they are kept, then revised to the producer's length once it runs.Follow-ups: #76445 (a re-run that maps to zero ends
removed, notskipped) and #76446 (restoring an index removed by a shorter list reports a Dag re-add and adds an empty try).closes: #76377
Was generative AI tooling used to co-author this PR?