Skip to content

Conversation

@Lee-W
Copy link
Member

@Lee-W Lee-W commented Jun 2, 2025

Why

closes: #50654

If an unexpected error occurs during task update, the API endpoint crashes with an unhandled exception, and the task state remains, causing the task to hang.

What

Set the task to fail if such case happens


^ 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 airflow-core/newsfragments.

@Lee-W Lee-W requested review from amoghrajesh, ashb and kaxil as code owners June 2, 2025 12:02
@boring-cyborg boring-cyborg bot added area:API Airflow's REST/HTTP API area:task-sdk labels Jun 2, 2025
@Lee-W Lee-W changed the title feat(task_instances): guard ti update state and set to fail if except… feat(task_instances): guard ti update state and set to fail if exception enounctered Jun 2, 2025
Copy link
Contributor

@amoghrajesh amoghrajesh left a comment

Choose a reason for hiding this comment

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

@Lee-W could you please update the PR description with the intent of why you are making this change?

@Lee-W Lee-W marked this pull request as draft June 2, 2025 12:20
@Lee-W
Copy link
Member Author

Lee-W commented Jun 2, 2025

@Lee-W could you please update the PR description with the intent of why you are making this change?

it should be a draft one. basically what we discussed this afternoon except for changing task runner is not correct. will update the descipriont after late dinner

@Lee-W Lee-W force-pushed the guard-ti-update-state branch from 8762ed8 to e724fd4 Compare June 2, 2025 13:50
@Lee-W Lee-W marked this pull request as ready for review June 2, 2025 13:51
@Lee-W Lee-W requested a review from amoghrajesh June 2, 2025 13:53
@Lee-W
Copy link
Member Author

Lee-W commented Jun 2, 2025

It would be nice if we could get this one and #50654 reviewed. IMO, the other one is more urgent and important

@Lee-W Lee-W added this to the Airflow 3.0.2 milestone Jun 2, 2025
@Lee-W Lee-W changed the title feat(task_instances): guard ti update state and set to fail if exception enounctered feat(task_instances): guard ti update state and set to fail if exception encountered Jun 2, 2025
@Lee-W Lee-W changed the title feat(task_instances): guard ti update state and set to fail if exception encountered feat(task_instances): guard ti update state and set task to fail if exception encountered Jun 2, 2025
@Lee-W Lee-W force-pushed the guard-ti-update-state branch 2 times, most recently from 0f08675 to 022fd63 Compare June 3, 2025 00:08
Copy link
Member

@uranusjr uranusjr left a comment

Choose a reason for hiding this comment

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

I think this makes sense. A couple of non-blocking comments.

@Lee-W Lee-W force-pushed the guard-ti-update-state branch from d534d82 to 3a34038 Compare June 3, 2025 02:20
@uranusjr
Copy link
Member

uranusjr commented Jun 3, 2025

Looks like the test failure is relevant.

@Lee-W
Copy link
Member Author

Lee-W commented Jun 3, 2025

Looks like the test failure is relevant.

Yes, I'm now working on it. Basically, we'll need to remove the future rescheulde from data

@Lee-W
Copy link
Member Author

Lee-W commented Jun 3, 2025

just rebuild the query to avoid mysql failure

@Lee-W Lee-W force-pushed the guard-ti-update-state branch from 0a28e64 to ac7ffcd Compare June 3, 2025 08:39
@Lee-W
Copy link
Member Author

Lee-W commented Jun 3, 2025

As it has been approved and we're about to start work on releasing 3.0.2, I will merge this one once the CI pass again

@Lee-W Lee-W merged commit b5a3b4e into apache:main Jun 3, 2025
94 checks passed
@Lee-W Lee-W deleted the guard-ti-update-state branch June 3, 2025 09:10
github-actions bot pushed a commit that referenced this pull request Jun 6, 2025
…to fail if exception encountered (#51295)

* feat(task_instances): guard ti update state and set to fail if exception enounctered

* feat(task_instances): catch mysql error and set the task to fail

* test: remove unnecessay check

* fix(task_instances): handle mysql error

* refactor(task-instances): merge mysql logic back to the original private function
(cherry picked from commit b5a3b4e)

Co-authored-by: Wei Lee <weilee.rx@gmail.com>
@github-actions
Copy link

github-actions bot commented Jun 6, 2025

Backport successfully created: v3-0-test

Status Branch Result
v3-0-test PR Link

kaxil pushed a commit that referenced this pull request Jun 6, 2025
…to fail if exception encountered (#51295) (#51470)

* feat(task_instances): guard ti update state and set to fail if exception enounctered

* feat(task_instances): catch mysql error and set the task to fail

* test: remove unnecessay check

* fix(task_instances): handle mysql error

* refactor(task-instances): merge mysql logic back to the original private function
(cherry picked from commit b5a3b4e)

Co-authored-by: Wei Lee <weilee.rx@gmail.com>
kaxil pushed a commit that referenced this pull request Jun 6, 2025
…to fail if exception encountered (#51295) (#51470)

* feat(task_instances): guard ti update state and set to fail if exception enounctered

* feat(task_instances): catch mysql error and set the task to fail

* test: remove unnecessay check

* fix(task_instances): handle mysql error

* refactor(task-instances): merge mysql logic back to the original private function
(cherry picked from commit b5a3b4e)

Co-authored-by: Wei Lee <weilee.rx@gmail.com>
sanederchik pushed a commit to sanederchik/airflow that referenced this pull request Jun 7, 2025
…xception encountered (apache#51295)

* feat(task_instances): guard ti update state and set to fail if exception enounctered

* feat(task_instances): catch mysql error and set the task to fail

* test: remove unnecessay check

* fix(task_instances): handle mysql error

* refactor(task-instances): merge mysql logic back to the original private function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:task-sdk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task is taking more than 5 minutes to fail

4 participants