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

Calendar view infinite loop for @continuous DAGs #37902

Closed
2 tasks done
tanelk opened this issue Mar 5, 2024 · 3 comments · Fixed by #37909
Closed
2 tasks done

Calendar view infinite loop for @continuous DAGs #37902

tanelk opened this issue Mar 5, 2024 · 3 comments · Fixed by #37909
Assignees
Labels
affected_version:2.8 Issues Reported for 2.8 area:webserver Webserver related Issues kind:bug This is a clearly a bug

Comments

@tanelk
Copy link
Contributor

tanelk commented Mar 5, 2024

Apache Airflow version

main (development)

If "Other Airflow 2 version" selected, which one?

No response

What happened?

The /dags/<string:dag_id>/calendar view does not open for DAGs, that have schedule='@continuous'.

It happens because this loop in airflow.www.views.Airflow.calendar is practically infinite.

while True:
    curr_info = dag.timetable.next_dagrun_info(
        last_automated_data_interval=last_automated_data_interval,
        restriction=restriction,
    )
    if curr_info is None:
        break  # Reached the end.
    if curr_info.logical_date <= prev_logical_date:
        break  # We're not progressing. Maybe a malformed timetable? Give up.
    if curr_info.logical_date.year != year:
        break  # Crossed the year boundary.
    last_automated_data_interval = curr_info.data_interval
    dates[curr_info.logical_date] += 1
    prev_logical_date = curr_info.logical_date

The prev_logical_date and curr_info.logical_date are both set to timezone.utcnow() at consecutive loop iterations. This is why curr_info.logical_date <= prev_logical_date never fails and curr_info.logical_date.year != year waits for the end of the year.

What you think should happen instead?

I'm not sure, what is the best way to solve this:

  1. Check if dag.timetable is ContinuousTimetable
  2. Limit the number of iterations
  3. Check that the diff between curr_info.logical_date and prev_logical_date is at least some amount - 1 minute or so.

How to reproduce

Make @continuous DAG and check the calendar view.

Operating System

Versions of Apache Airflow Providers

No response

Deployment

Other

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

@tanelk tanelk added area:core kind:bug This is a clearly a bug needs-triage label for new issues that we didn't triage yet labels Mar 5, 2024
@tanelk
Copy link
Contributor Author

tanelk commented Mar 5, 2024

On a related note, the incrementing line in the snipet should be: dates[curr_info.logical_date.date()] += 1

@tanelk tanelk changed the title Calendar view infinite loop for @continuous DAGs Calendar view infinite loop for @continuous DAGs Mar 5, 2024
@Taragolis Taragolis added area:webserver Webserver related Issues affected_version:2.8 Issues Reported for 2.8 and removed area:core needs-triage label for new issues that we didn't triage yet labels Mar 5, 2024
@eladkal
Copy link
Contributor

eladkal commented Mar 5, 2024

cc @bbovenzi worth checking with the new calendar view

@bbovenzi
Copy link
Contributor

bbovenzi commented Mar 5, 2024

On a related note, the incrementing line in the snipet should be: dates[curr_info.logical_date.date()] += 1

Oh yeah, I caught that one when working on the new calendar view.
Let me also add a fix for continuous schedules

@bbovenzi bbovenzi self-assigned this Mar 5, 2024
@eladkal eladkal linked a pull request Mar 5, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affected_version:2.8 Issues Reported for 2.8 area:webserver Webserver related Issues kind:bug This is a clearly a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants