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

ZeroDivisionError in BaseSensorOperator with exponential_backoff=True and poke_interval=1 #31409

Closed
2 tasks done
AVMusorin opened this issue May 19, 2023 · 2 comments · Fixed by #31412
Closed
2 tasks done
Assignees
Labels
area:core-operators Operators, Sensors and hooks within Core Airflow kind:bug This is a clearly a bug

Comments

@AVMusorin
Copy link
Contributor

Apache Airflow version

2.6.1

What happened

Sensor is fired with an exception ZeroDivisionError, if set up mode="reschedule", exponential_backoff=True and poke_interval=1

ERROR - Task failed with exception
Traceback (most recent call last):
  File "/home/airflow/.local/lib/python3.9/site-packages/airflow/sensors/base.py", line 244, in execute
    next_poke_interval = self._get_next_poke_interval(started_at, run_duration, try_number)
  File "/home/airflow/.local/lib/python3.9/site-packages/airflow/sensors/base.py", line 274, in _get_next_poke_interval
    modded_hash = min_backoff + run_hash % min_backoff
ZeroDivisionError: integer division or modulo by zero

What you think should happen instead

Throw an human-readable exception about corner values for poke_interval or allow to set up this value less then 2 (if it's >= 2 - rescheduling works fine.)

How to reproduce

from airflow.sensors.base import BaseSensorOperator
from airflow import DAG
import datetime

class TestSensor(BaseSensorOperator):
    def poke(self, context):
        return False

with DAG("test_dag", start_date=datetime.datetime.today(), schedule=None):
    sensor = TestSensor(task_id="sensor", mode="reschedule", poke_interval=1, exponential_backoff=True, max_wait=5)

Operating System

Debian GNU/Linux 10 (buster)

Versions of Apache Airflow Providers

No response

Deployment

Docker-Compose

Deployment details

No response

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@AVMusorin AVMusorin added area:core kind:bug This is a clearly a bug needs-triage label for new issues that we didn't triage yet labels May 19, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented May 19, 2023

Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

@AVMusorin
Copy link
Contributor Author

Might be cohere with #30669

@hussein-awala hussein-awala self-assigned this May 19, 2023
@hussein-awala hussein-awala removed the needs-triage label for new issues that we didn't triage yet label May 19, 2023
@hussein-awala hussein-awala added area:core-operators Operators, Sensors and hooks within Core Airflow and removed area:core labels May 19, 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 kind:bug This is a clearly a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants