Fix clearing mapped task instances in same group to respect depth-fir… #60016
+89
−0
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.
Fix clearing mapped task instances in same group to respect depth-first execution (#40543)
Problem
When clearing a specific mapped task instance within a mapped task group (e.g.,
etl.e[1]), the system incorrectly cleared ALL downstream task instances (etl.t[]andetl.l[]) instead of only the relevant ones with the samemap_index(etl.t[1]andetl.l[1]). This violated the depth-first execution model where each mapped instance should operate independently.Solution
Added explicit handling in
_get_relevant_map_indexes()to detect when two tasks are siblings in the same mapped task group. Whenti_count == ancestor_ti_count, the function now returns the samemap_indexdirectly, ensuring depth-first execution is maintained.Changes
Modified
airflow-core/src/airflow/models/taskinstance.py:_get_relevant_map_indexes()for same-group siblingsmap_indexdirectly whenti_count == ancestor_ti_countAdded tests in
airflow-core/tests/unit/models/test_taskinstance.py:test_find_relevant_relatives_downstream_same_group_siblings: Parametrized test for map_indexes 0, 1, 2test_find_relevant_relatives_upstream_same_group_siblings: Test for upstream directionTesting
All 11
find_relevant_relativestests pass, including: