From 84ba36051507a288a83f6f804774a6591b50057f Mon Sep 17 00:00:00 2001 From: Aleksandr Andreev <137277646+alealandreev@users.noreply.github.com> Date: Wed, 26 Mar 2025 10:36:45 +0300 Subject: [PATCH] Issue47971SolutionPatch --- airflow-core/src/airflow/models/taskinstance.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/airflow-core/src/airflow/models/taskinstance.py b/airflow-core/src/airflow/models/taskinstance.py index 66975f57815ea..51e5166599c1a 100644 --- a/airflow-core/src/airflow/models/taskinstance.py +++ b/airflow-core/src/airflow/models/taskinstance.py @@ -2350,6 +2350,7 @@ 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, @@ -2357,7 +2358,10 @@ def next_retry_datetime(self): # 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