Apache Airflow version
2.11.0
If "Other Airflow 2 version" selected, which one?
N/A
What happened?
Triggers of task instances that belongs to a deactivated dag continues to run until it fires.
The behaviour is described in the Airflow documentation as such though with little clarification around certain pitfalls like what happens when a dag is deactivated or when paused.
The trigger runs until it fires, at which point its source task is re-scheduled by the scheduler.
What you think should happen instead?
When a dag is paused, the triggers tied to the task instance belonging to the dag should be "paused" as well. The triggerer should skip or ignore them. Once the dag is unpaused, the trigger should be ran (and potentially fire). Currently, regardless of the dag (or dagrun) state, the task instance will be marked as scheduled if the trigger fires.
Another variant of the behaviour is when the dag is deactivated which essentially means the dag is "paused". Though in this case, I think the trigger should be deleted and the task marked as failed.
In either case, perhaps, having the trigger fire an event that indicate the corresponding dag has been deactivated or paused is ideal so that trigger can decided what to do in those scenarios.
How to reproduce
To reproducible in Airflow 2.11.0, I followed these steps:
- Create a dag with a deferrable TI and start a dagrun
- Wait for the TI to enter the deferred state
- Pause the dag
- Check the task logs
The same behaviour can be reproduced for deactivated dags
- Create a dag with a deferrable TI and start a dagrun
- Wait for the TI to enter the deferred state
- Remove the dag from the dags folder
- Confirm dag is deactivate and the TI is deferred
- Check the task logs
I used the DateTimeSensorAsync (apache-airflow-providers-standard==1.6.0) sensor to demostrate the behaviour.
from airflow import DAG
from airflow.providers.standard.sensors.date_time import DateTimeSensorAsync
from datetime import datetime
with DAG(
dag_id="testing_dag",
schedule_interval="@daily",
start_date=datetime(2023, 1, 1),
catchup=False
) as dag:
c = DateTimeSensorAsync(
task_id='wait_for_time',
target_time="""{{ macros.datetime.utcnow() + macros.timedelta(minutes=1) }}"""
)
Operating System
Debian
Versions of Apache Airflow Providers
No response
Deployment
Official Apache Airflow Helm Chart
Deployment details
No response
Anything else?
No response
Are you willing to submit PR?
Code of Conduct
Apache Airflow version
2.11.0
If "Other Airflow 2 version" selected, which one?
N/A
What happened?
Triggers of task instances that belongs to a deactivated dag continues to run until it fires.
The behaviour is described in the Airflow documentation as such though with little clarification around certain pitfalls like what happens when a dag is deactivated or when paused.
What you think should happen instead?
When a dag is paused, the triggers tied to the task instance belonging to the dag should be "paused" as well. The triggerer should skip or ignore them. Once the dag is unpaused, the trigger should be ran (and potentially fire). Currently, regardless of the dag (or dagrun) state, the task instance will be marked as scheduled if the trigger fires.
Another variant of the behaviour is when the dag is deactivated which essentially means the dag is "paused". Though in this case, I think the trigger should be deleted and the task marked as failed.
In either case, perhaps, having the trigger fire an event that indicate the corresponding dag has been deactivated or paused is ideal so that trigger can decided what to do in those scenarios.
How to reproduce
To reproducible in Airflow 2.11.0, I followed these steps:
The same behaviour can be reproduced for deactivated dags
I used the
DateTimeSensorAsync(apache-airflow-providers-standard==1.6.0) sensor to demostrate the behaviour.Operating System
Debian
Versions of Apache Airflow Providers
No response
Deployment
Official Apache Airflow Helm Chart
Deployment details
No response
Anything else?
No response
Are you willing to submit PR?
Code of Conduct