You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ndellosa95 (via GitHub)" <gi...@apache.org> on 2026/01/06 16:25:52 UTC
[I] Enable conditional retry logic in `on_retry_callback` in Airflow 3 [airflow]
ndellosa95 opened a new issue, #60172:
URL: https://github.com/apache/airflow/issues/60172
### Description
This was previously possible in Airflow 2 using [this solution](https://github.com/apache/airflow/discussions/28263#discussioncomment-4354509). However, in Airflow 3 `RuntimeTaskInstanceProtocol` does not expose a method for modifying the task state directly.
My suggestion would be to create a new exception type that can be raised from `on_retry_callback` to request a state change to either success or failure.
### Use case/motivation
We have some long-running tasks (>24hr) that sometimes fail fast due to transient issues. We want to be able to retry whenever these fast fails occur. However, if a failure occurs hours into the task, we would prefer not to retry, as the task must be completed by a certain time and failures of this sort typically represent an actual issue we want to look into.
### Related issues
Just the discussion item [here](https://github.com/apache/airflow/discussions/28263) from years ago as far as I can tell.
### Are you willing to submit a PR?
- [x] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
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.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Fix handling AirflowFailException `on_retry_callback` [airflow]
Posted by "ndellosa95 (via GitHub)" <gi...@apache.org>.
ndellosa95 commented on issue #60172:
URL: https://github.com/apache/airflow/issues/60172#issuecomment-3739427319
@developer-ravi-03 I worked on this some Friday and just threw up a [draft PR](https://github.com/apache/airflow/pull/60415) if you want to take a look.
--
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: [I] Fix handling AirflowFailException `on_retry_callback` [airflow]
Posted by "IvanildoBarauna (via GitHub)" <gi...@apache.org>.
IvanildoBarauna commented on issue #60172:
URL: https://github.com/apache/airflow/issues/60172#issuecomment-4122476690
I working 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: [I] Enable conditional retry logic in `on_retry_callback` in Airflow 3 [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on issue #60172:
URL: https://github.com/apache/airflow/issues/60172#issuecomment-3715415092
Described in the docs here https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/tasks.html#special-exceptions
--
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: [I] Enable conditional retry logic in `on_retry_callback` in Airflow 3 [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on issue #60172:
URL: https://github.com/apache/airflow/issues/60172#issuecomment-3715410867
There is already exception for that:
```
class AirflowFailException(AirflowException):
"""Raise when the task should be failed without retrying."""
```
There is no need to have "success" exception, you just exit from the method when it happens
--
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: [I] Fix handling AirflowFailException `on_retry_callback` [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on issue #60172:
URL: https://github.com/apache/airflow/issues/60172#issuecomment-3720648786
I assigned you, as you stated you would like to fix it - it does not seem too complex to fix. It's just a matter of being aware that callback can handle AirflowFailedException and handle it appropriately.
--
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: [I] Fix handling AirflowFailException `on_retry_callback` [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on issue #60172:
URL: https://github.com/apache/airflow/issues/60172#issuecomment-3720654087
BTW. I did not misuderstand your request - I was **just** surprised it does not work this way already.
--
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: [I] Enable conditional retry logic in `on_retry_callback` in Airflow 3 [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk closed issue #60172: Enable conditional retry logic in `on_retry_callback` in Airflow 3
URL: https://github.com/apache/airflow/issues/60172
--
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: [I] Enable conditional retry logic in `on_retry_callback` in Airflow 3 [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on issue #60172:
URL: https://github.com/apache/airflow/issues/60172#issuecomment-3720619622
So I guess you are saying that it's a bug in handling this exception - because there is no reason why raising AirflowFailException in on_retry_callback shoudl continue retrying. If that's the case, then this is a bug IMHO
--
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: [I] Enable conditional retry logic in `on_retry_callback` in Airflow 3 [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on issue #60172:
URL: https://github.com/apache/airflow/issues/60172#issuecomment-3715361629
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
--
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: [I] Fix handling AirflowFailException `on_retry_callback` [airflow]
Posted by "developer-ravi-03 (via GitHub)" <gi...@apache.org>.
developer-ravi-03 commented on issue #60172:
URL: https://github.com/apache/airflow/issues/60172#issuecomment-3732550262
Hi @potiuk and @ndellosa95,
Thanks for the clarification — that makes sense.
I’d like to help with this fix if it’s okay.
My understanding is that `on_retry_callback` should explicitly catch and propagate `AirflowFailException` so the task is marked failed and retries stop, instead of treating it as a normal callback failure.
If you’re fine with it, I can:
- Locate where `on_retry_callback` is invoked
- Add explicit handling for `AirflowFailException`
- Add a regression test to cover this behavior
Please let me know if I should proceed or coordinate with @ndellosa95.
--
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: [I] Fix handling AirflowFailException `on_retry_callback` [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on issue #60172:
URL: https://github.com/apache/airflow/issues/60172#issuecomment-3986416580
@ndellosa95 We are unassigning you from this issue as part of our updated [assignment policy](https://github.com/apache/airflow/blob/main/contributing-docs/04_how_to_contribute.rst#contribute-code-changes).
This is not meant to discourage your contribution — quite the opposite! You are still very welcome to work on this issue and submit a PR for it. Simply comment that you are working on it and open a PR when ready.
We found that formal assignments were not working well, as they often prevented others from contributing when the assignee was not actively working on the issue.
--
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: [I] Enable conditional retry logic in `on_retry_callback` in Airflow 3 [airflow]
Posted by "ndellosa95 (via GitHub)" <gi...@apache.org>.
ndellosa95 commented on issue #60172:
URL: https://github.com/apache/airflow/issues/60172#issuecomment-3720005072
@potiuk I think you are misunderstanding my request. `AirflowFailException` only works when called from within operator/task code. When you call it within an `on_retry_callback` it simply fails the callback and retries as normal. See the example [here](https://github.com/apache/airflow/discussions/28263#discussioncomment-4354509), which I linked above, for what I mean.
--
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