Fix float overflow for retry_exponential_backoff #48051
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.rstor{issue_number}.significant.rst, in newsfragments.