Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion airflow-core/src/airflow/models/taskinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2379,14 +2379,18 @@ def next_retry_datetime(self):
"""
from airflow.models.abstractoperator import MAX_RETRY_DELAY

max_try_number = 500
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.
# this probably gives unexpected results if a task instance has previously been cleared,
# because try_number can increase without bound
min_backoff = math.ceil(delay.total_seconds() * (2 ** (self.try_number - 1)))
if self.try_number < max_try_number:
min_backoff = math.ceil(delay.total_seconds() * (2 ** (self.try_number - 1)))
else:
min_backoff = math.ceil(delay.total_seconds() * (2 ** (max_try_number - 1)))

# In the case when delay.total_seconds() is 0, min_backoff will not be rounded up to 1.
# To address this, we impose a lower bound of 1 on min_backoff. This effectively makes
Expand Down