Skip to content

Conversation

@shahar1
Copy link
Contributor

@shahar1 shahar1 commented Nov 23, 2024

closes: #44245


Cause

The query for fetching the stats of task instances groups them by task_id, run_id, state, and try_number. However, using try_number for dynamic mapped tasks leads to incorrect results as individual tasks within the mapping might have different try_number values.

Example

Let's say that within a dynamic mapped task there were 10 expansions - 4 of them failed in the first time and reran (i.e., try_number = 2).
image

In this case, the API response will eventually show only statistics regarding the most recent try_number.

image

Note

Intermediate results might not exactly follow the latter pattern, as they also depend on the
TaskInstance.state parameter of the group_by.

Solution

In the query, avoid grouping by try_number only for dynamic mapped tasks (map_index != -1).


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@shahar1 shahar1 added area:webserver Webserver related Issues type:bug-fix Changelog: Bug Fixes area:dynamic-task-mapping AIP-42 labels Nov 23, 2024
@shahar1 shahar1 changed the title Avoid grouping task instance stats by try_number for dynamic mapped tasks Fix stats of dynamic mapped tasks after automatic retries of failed tasks Nov 23, 2024
Copy link
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was reading the text multiple times and still have trouble understanding the query logic... but I can confirm it fixes the problem.

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NICE!

@potiuk potiuk merged commit 5e52bd2 into apache:main Nov 24, 2024
github-actions bot pushed a commit that referenced this pull request Nov 24, 2024
…amic mapped tasks (#44300)

(cherry picked from commit 5e52bd2)

Co-authored-by: Shahar Epstein <60007259+shahar1@users.noreply.github.com>
@github-actions
Copy link

Backport successfully created: v2-10-test

Status Branch Result
v2-10-test PR Link

@shahar1 shahar1 deleted the fix-44245 branch November 24, 2024 06:29
potiuk pushed a commit that referenced this pull request Nov 24, 2024
…amic mapped tasks (#44300) (#44319)

* [v2-10-test] Avoid grouping task instance stats by try_number for dynamic mapped tasks (#44300)
(cherry picked from commit 5e52bd2)

Co-authored-by: Shahar Epstein <60007259+shahar1@users.noreply.github.com>

* Update test_views_grid.py

---------

Co-authored-by: Shahar Epstein <60007259+shahar1@users.noreply.github.com>
utkarsharma2 pushed a commit that referenced this pull request Dec 4, 2024
…amic mapped tasks (#44300) (#44319)

* [v2-10-test] Avoid grouping task instance stats by try_number for dynamic mapped tasks (#44300)
(cherry picked from commit 5e52bd2)

Co-authored-by: Shahar Epstein <60007259+shahar1@users.noreply.github.com>

* Update test_views_grid.py

---------

Co-authored-by: Shahar Epstein <60007259+shahar1@users.noreply.github.com>
utkarsharma2 pushed a commit that referenced this pull request Dec 9, 2024
…amic mapped tasks (#44300) (#44319)

* [v2-10-test] Avoid grouping task instance stats by try_number for dynamic mapped tasks (#44300)
(cherry picked from commit 5e52bd2)

Co-authored-by: Shahar Epstein <60007259+shahar1@users.noreply.github.com>

* Update test_views_grid.py

---------

Co-authored-by: Shahar Epstein <60007259+shahar1@users.noreply.github.com>
got686-yandex pushed a commit to got686-yandex/airflow that referenced this pull request Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dynamic-task-mapping AIP-42 area:webserver Webserver related Issues type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stats of a dynamic mapped tasks disappear after an automatic retry of a failed task

4 participants