Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clearing child dag mapped tasks from parent dag #27501

Merged
merged 4 commits into from
Nov 17, 2022

Conversation

zhiyong-ong
Copy link
Contributor

@zhiyong-ong zhiyong-ong commented Nov 4, 2022

This fixes the bug where clearing a parent dag will not clear the child dag's mapped task.

The bug was due to TaskInstanceKey accepting its attributes in the order (dag_id, task_id, run_id, try_number, map_index) while in _get_task_instances, the pk_tuple that we pass into TaskInstanceKey to get the result is (dag_id, task_id, run_id, map_index), missing out the try_number. So TaskInstanceKey assumes that the map_index value supplied is try_number and defaults the value of map_index to -1. This causes a bunch of problems downstream when we try and retrieve the TaskInstance from the table using the map_index as part of the filter.

fixes: #27462

@boring-cyborg boring-cyborg bot added the area:core-operators Operators, Sensors and hooks within Core Airflow label Nov 4, 2022
@zhiyong-ong zhiyong-ong marked this pull request as ready for review November 4, 2022 09:48
@potiuk potiuk requested a review from uranusjr November 7, 2022 21:52
airflow/models/dag.py Outdated Show resolved Hide resolved
@zhiyong-ong zhiyong-ong force-pushed the fix-mapped-task-recursive-clearing branch from a27e48a to e13ca42 Compare November 16, 2022 19:43
@potiuk
Copy link
Member

potiuk commented Nov 16, 2022

Static checks need fixing.

@uranusjr uranusjr changed the title fix clearing child dag mapped tasks from parent dag Fix clearing child dag mapped tasks from parent dag Nov 17, 2022
@uranusjr uranusjr merged commit 5ce9c82 into apache:main Nov 17, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Nov 17, 2022

Awesome work, congrats on your first merged pull request!

@ephraimbuddy ephraimbuddy added the type:bug-fix Changelog: Bug Fixes label Nov 22, 2022
@yuqian90 yuqian90 added this to the Airflow 2.4.4 milestone Nov 22, 2022
@ephraimbuddy ephraimbuddy modified the milestones: Airflow 2.4.4, Airflow 2.5.0 Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core-operators Operators, Sensors and hooks within Core Airflow type:bug-fix Changelog: Bug Fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clearing the parent dag will not clear child dag's mapped tasks
5 participants