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

The TI doesn't wait setup tasks when they are not a direct upstream #33561

Closed
2 tasks done
hussein-awala opened this issue Aug 20, 2023 · 2 comments
Closed
2 tasks done
Assignees
Labels
AIP-52 Automatic setup and teardown tasks area:core kind:bug This is a clearly a bug Stale Bug Report

Comments

@hussein-awala
Copy link
Member

Apache Airflow version

2.7.0

What happened

When we add a setup task (let's call it S) before a sequence of tasks, and we clear the state of a not direct downstream task for the setup task (let's call it T), the state of S is correctly cleared, but the task T doesn't wait for S, they are running in parallel.

What you think should happen instead

The setup task should be treated as an upstream for all the downstream tasks

How to reproduce

from datetime import datetime

from airflow.models import DAG
from airflow.operators.python import PythonOperator

def sleep_and_log(msg):
    import time
    
    time.sleep(5)
    print(msg)



with DAG(
    dag_id="test_setup_teardown",
    schedule_interval=None,
    start_date=datetime(2023, 8, 20),
    catchup=False,
):
    setup_task = PythonOperator(
        task_id="setup_task",
        python_callable=lambda: sleep_and_log("setup_task"),
    ).as_setup()

    teardown_task = PythonOperator(
        task_id="teardown_task",
        python_callable=lambda: sleep_and_log("teardown_task"),
    ).as_teardown(setups=[setup_task])

    t1 = PythonOperator(
        task_id="t1",
        python_callable=lambda: sleep_and_log("t1"),
    )

    t2 = PythonOperator(
        task_id="t2",
        python_callable=lambda: sleep_and_log("t2"),
    )

    setup_task >> t1 >> t2 >> teardown_task

Create a run and wait all the tasks to finish, then clear the state of t2, the setup task and t2 states will be cleared, and both tasks will run in parallel.

Operating System

Debian GNU/Linux

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

@hussein-awala hussein-awala added kind:bug This is a clearly a bug area:core AIP-52 Automatic setup and teardown tasks labels Aug 20, 2023
@hussein-awala hussein-awala self-assigned this Aug 20, 2023
@hussein-awala hussein-awala changed the title The TI doesn't wait setup task when they are not a direct upstream The TI doesn't wait setup tasks when they are not a direct upstream Aug 20, 2023
Copy link

This issue has been automatically marked as stale because it has been open for 365 days without any activity. There has been several Airflow releases since last activity on this issue. Kindly asking to recheck the report against latest Airflow version and let us know if the issue is reproducible. The issue will be closed in next 30 days if no further activity occurs from the issue author.

Copy link

This issue has been closed because it has not received response from the issue author.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AIP-52 Automatic setup and teardown tasks area:core kind:bug This is a clearly a bug Stale Bug Report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant