You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/09/29 21:17:27 UTC

[GitHub] [airflow] potiuk commented on a change in pull request #17003: Fix `retry_exponential_backoff` divide by zero error when retry delay is zero

potiuk commented on a change in pull request #17003:
URL: https://github.com/apache/airflow/pull/17003#discussion_r718891746



##########
File path: airflow/models/taskinstance.py
##########
@@ -939,9 +939,9 @@ def next_retry_datetime(self):
         delay = self.task.retry_delay
         if self.task.retry_exponential_backoff:
             # If the min_backoff calculation is below 1, it will be converted to 0 via int. Thus,
-            # we must round up prior to converting to an int, otherwise a divide by zero error
-            # will occur in the modded_hash calculation.
-            min_backoff = int(math.ceil(delay.total_seconds() * (2 ** (self.try_number - 2))))
+            # we must impose a lower bound of 1 prior to converting to an int, otherwise a divide
+            # by zero error will occur in the modded_hash calculation.
+            min_backoff = int(max(1, delay.total_seconds() * (2 ** (self.try_number - 2))))

Review comment:
       I am good with the approach as is now. @eladkal ?




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