Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix min_backoff calculation in base sensor when exponential_backoff is on #31412

Merged
merged 3 commits into from
May 23, 2023

Conversation

hussein-awala
Copy link
Member

@hussein-awala hussein-awala commented May 19, 2023

closes: #31409

Make sensor poking exponential backoff consistent with TI retrying exponential backoff:

min_backoff = int(math.ceil(delay.total_seconds() * (2 ** (self.try_number - 2))))
# 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
# the ceiling function unnecessary, but the ceiling function was retained to avoid
# introducing a breaking change.
if min_backoff < 1:
min_backoff = 1


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

@boring-cyborg boring-cyborg bot added the area:core-operators Operators, Sensors and hooks within Core Airflow label May 19, 2023
@hussein-awala hussein-awala added this to the Airflow 2.6.2 milestone May 19, 2023
@@ -265,7 +265,8 @@ def _get_next_poke_interval(
if not self.exponential_backoff:
return self.poke_interval

min_backoff = int(self.poke_interval * (2 ** (try_number - 2)))
# The value of min_backoff should always be greater than or equal to 1.
min_backoff = max(int(self.poke_interval * (2 ** (try_number - 2))), 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can be able to add test for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you check the test which I just added?

@uranusjr uranusjr merged commit a98621f into apache:main May 23, 2023
@eladkal eladkal added the type:bug-fix Changelog: Bug Fixes label Jun 8, 2023
eladkal pushed a commit that referenced this pull request Jun 8, 2023
eladkal pushed a commit that referenced this pull request Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core-operators Operators, Sensors and hooks within Core Airflow type:bug-fix Changelog: Bug Fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ZeroDivisionError in BaseSensorOperator with exponential_backoff=True and poke_interval=1
4 participants