Skip to content

Conversation

@alealandreev
Copy link

@alealandreev alealandreev commented Mar 21, 2025

Fixed float overflow for exponential_backoff calculation. I encountered with error when retry_delay = 5 minutes, max_retry_delay=1 hour, retry_exponential_backoff is True and retries=1000 in DAG configuration. In this case Scheduler brokes down on ~1000 retry due to float overflow (delay is calculating on each retry) and after 1000 retries DAG is still trying to start. So total number of retries I encountered is 1017, which is more than 1000. This is due to this formula in line 2657 in taskinstance.py: min_backoff = math.ceil(delay.total_seconds() * (2 ** (self.try_number - 1))). We should limit degree to reasonable value, such as 30 for instance. After that we need to avoid all possible exceptions. This fix repairs exponential backoff logic, so float overflow will never happen. Also if DAG started after many retries, worked some large time (for instance 4 hours) and then failed again then next try happens not after max_retry time or delay with exponential backoff but after base delay.


^ 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.

Fixed float overflow for exponential_backoff calculation. I encountered with error when retry_delay = 5 minutes, max_retry_delay=1 hour, retry_exponential_backoff is True and retries=1000 in DAG configuration. In this case Scheduler brokes down on ~1000 retry due to float overflow (delay is calculating on each retry) and after 1000 retries DAG is still trying to start. So total number of retries I encountered is 1017, which is more than 1000. This is due to this formula in line 2657 in taskinstance.py: min_backoff = math.ceil(delay.total_seconds() * (2 ** (self.try_number - 1))).
We should limit degree to reasonable value, such as 30 for instance. After that we need to avoid all possible exceptions. This fix repairs exponential backoff logic, so float overflow will never happen.
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.

This code is quite long and complicated. How about just catching the exception and providing better log error?

Sometimes "simplicity" trumps "correctnes", and I think just catching the exception and providing a reasonable explanation for the case that is very unlikely is a better approach.

@ashb
Copy link
Member

ashb commented Mar 24, 2025

See also #48057 (comment)

@potiuk
Copy link
Member

potiuk commented Mar 30, 2025

Closing this in favour of #48057

@potiuk potiuk closed this Mar 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants