You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "karenbraganz (via GitHub)" <gi...@apache.org> on 2025/07/08 18:52:10 UTC
[PR] [v2-11-test] Call executor fail method for stuck in queued tasks [airflow]
karenbraganz opened a new pull request, #53038:
URL: https://github.com/apache/airflow/pull/53038
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #51301
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
In issues #51301, it was reported that failure callbacks do not run for task instances that get stuck in queued and fail in Airflow 2.10.5. This is happening due to the changes introduced in PR #43520. In this PR, logic was introduced to requeue tasks that get stuck in queued (up to two times by default) before failing them.
Previously, the executor's fail method was called when the task needed to be failed after max requeue attempts. This was replaced by the task instance's set_state method in the PR `ti.set_state(TaskInstanceState.FAILED, session=session)`. Without the executor's fail method being called, failure callbacks will not be executed for such task instances. Therefore, I changed the code to call the executor's fail method instead.
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
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](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [v2-11-test] Allow failure callbacks for stuck in queued TIs that fail [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #53038:
URL: https://github.com/apache/airflow/pull/53038#issuecomment-3897720430
Nicely green now... Merging.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [v2-11-test] Call executor fail method for stuck in queued tasks [airflow]
Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on PR #53038:
URL: https://github.com/apache/airflow/pull/53038#issuecomment-3104497241
> LGTM - providing that #53435 will also be merged :)
Yeah, let's get that one merged first
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [v2-11-test] Allow failure callbacks for stuck in queued TIs that fail [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on PR #53038:
URL: https://github.com/apache/airflow/pull/53038#issuecomment-3870655557
@karenbraganz can you rebase and resolve conflicts?
cc @potiuk another candidate for 2.11.1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [v2-11-test] Allow failure callbacks for stuck in queued TIs that fail [airflow]
Posted by "karenbraganz (via GitHub)" <gi...@apache.org>.
karenbraganz commented on PR #53038:
URL: https://github.com/apache/airflow/pull/53038#issuecomment-3445173133
Just need to figure out why one of the checks is failing. I think it might have something to do with the rich-click package version being used.
Everything else is completed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [v2-11-test] Allow failure callbacks for stuck in queued TIs that fail [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #53038:
URL: https://github.com/apache/airflow/pull/53038#issuecomment-3397848934
> @eladkal I had to make some changes there. Let me see if the changes are needed here as well.
@karenbraganz -> did you check it ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [v2-11-test] Allow failure callbacks for stuck in queued TIs that fail [airflow]
Posted by "karenbraganz (via GitHub)" <gi...@apache.org>.
karenbraganz commented on PR #53038:
URL: https://github.com/apache/airflow/pull/53038#issuecomment-3403256027
@potiuk There are a few changes that I need to make. Working on the changes now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [v2-11-test] Allow failure callbacks for stuck in queued TIs that fail [airflow]
Posted by "karenbraganz (via GitHub)" <gi...@apache.org>.
karenbraganz commented on PR #53038:
URL: https://github.com/apache/airflow/pull/53038#issuecomment-3408859006
I still need to run some tests to ensure my changes work as expected.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [v2-11-test] Allow failure callbacks for stuck in queued TIs that fail [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #53038:
URL: https://github.com/apache/airflow/pull/53038#issuecomment-3884839055
I rebased your changes @karenbraganz -> @kaxil maybe you want to have a look before I merge it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [v2-11-test] Allow failure callbacks for stuck in queued TIs that fail [airflow]
Posted by "karenbraganz (via GitHub)" <gi...@apache.org>.
karenbraganz commented on PR #53038:
URL: https://github.com/apache/airflow/pull/53038#issuecomment-3453199936
Going to close and re-open the PR to re-trigger tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [v2-11-test] Allow failure callbacks for stuck in queued TIs that fail [airflow]
Posted by "karenbraganz (via GitHub)" <gi...@apache.org>.
karenbraganz commented on PR #53038:
URL: https://github.com/apache/airflow/pull/53038#issuecomment-3453192017
I had to make changes to airflow/www/static/js/types/api-generated.ts because one of the CI hooks was failing. My changes are not related to the UI.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [v2-11-test] Allow failure callbacks for stuck in queued TIs that fail [airflow]
Posted by "karenbraganz (via GitHub)" <gi...@apache.org>.
karenbraganz commented on PR #53038:
URL: https://github.com/apache/airflow/pull/53038#issuecomment-3314309376
@eladkal I had to make some changes there. Let me see if the changes are needed here as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [v2-11-test] Call executor fail method for stuck in queued tasks [airflow]
Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on code in PR #53038:
URL: https://github.com/apache/airflow/pull/53038#discussion_r2216166065
##########
airflow/jobs/scheduler_job_runner.py:
##########
@@ -1801,10 +1801,7 @@ def _handle_tasks_stuck_in_queued(self, session: Session = NEW_SESSION) -> None:
try:
for ti in stuck_tis:
executor.revoke_task(ti=ti)
- self._maybe_requeue_stuck_ti(
- ti=ti,
- session=session,
- )
+ self._maybe_requeue_stuck_ti(ti=ti, session=session, executor=executor)
Review Comment:
We don't do this in main, do you think that should be updated too? or is it 2.* specific? If latter, why?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [v2-11-test] Allow failure callbacks for stuck in queued TIs that fail [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #53038:
URL: https://github.com/apache/airflow/pull/53038
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [v2-11-test] Allow failure callbacks for stuck in queued TIs that fail [airflow]
Posted by "karenbraganz (via GitHub)" <gi...@apache.org>.
karenbraganz closed pull request #53038: [v2-11-test] Allow failure callbacks for stuck in queued TIs that fail
URL: https://github.com/apache/airflow/pull/53038
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [v2-11-test] Call executor fail method for stuck in queued tasks [airflow]
Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on PR #53038:
URL: https://github.com/apache/airflow/pull/53038#issuecomment-3058310623
tests are failing:
```
FAILED tests/jobs/test_scheduler_job.py::TestSchedulerJob::test_handle_stuck_queued_tasks_multiple_attempts - AssertionError: assert equals failed
[ [
'queued', 'failed',
'queued', 'failed',
] ]
FAILED tests/jobs/test_scheduler_job.py::TestSchedulerJob::test_handle_stuck_queued_tasks_reschedule_sensors - AssertionError: Expected 'fail' to not have been called. Called 2 times.
Calls: [call(TaskInstanceKey(dag_id='test_fail_stuck_queued_tasks_multiple_executors', task_id='op1', run_id='45e7135c-8e2c-4e07-8d35-4bea8c0232d6', try_number=0, map_index=-1)),
call(TaskInstanceKey(dag_id='test_fail_stuck_queued_tasks_multiple_executors', task_id='op2', run_id='45e7135c-8e2c-4e07-8d35-4bea8c0232d6', try_number=0, map_index=-1))].
pytest introspection follows:
Args:
assert equals failed
( ()
TaskInstanceKey(dag_id='test_
fail_stuck_queued_tasks_multipl
e_executors', task_id='op2', ru
n_id='45e7135c-8e2c-4e07-8d35-4
bea8c0232d6', try_number=0, map
_index=-1),
)
=========== 2 failed, 2035 passed, 959 skipped in 655.53s (0:10:55) ============
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [v2-11-test] Call executor fail method for stuck in queued tasks [airflow]
Posted by "karenbraganz (via GitHub)" <gi...@apache.org>.
karenbraganz commented on PR #53038:
URL: https://github.com/apache/airflow/pull/53038#issuecomment-3067454811
@kaxil all tests are passing now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [v2-11-test] Call executor fail method for stuck in queued tasks [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #53038:
URL: https://github.com/apache/airflow/pull/53038#discussion_r2218809337
##########
airflow/jobs/scheduler_job_runner.py:
##########
@@ -1801,10 +1801,7 @@ def _handle_tasks_stuck_in_queued(self, session: Session = NEW_SESSION) -> None:
try:
for ti in stuck_tis:
executor.revoke_task(ti=ti)
- self._maybe_requeue_stuck_ti(
- ti=ti,
- session=session,
- )
+ self._maybe_requeue_stuck_ti(ti=ti, session=session, executor=executor)
Review Comment:
It is implemented in separate PR https://github.com/apache/airflow/pull/53435 @kaxil ..
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [v2-11-test] Allow failure callbacks for stuck in queued TIs that fail [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on PR #53038:
URL: https://github.com/apache/airflow/pull/53038#issuecomment-3307259132
I see https://github.com/apache/airflow/pull/53435 is merged
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org