You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "wolfier (via GitHub)" <gi...@apache.org> on 2025/08/25 22:46:19 UTC
[I] Triggers of a task instance that belongs to a deactivated / paused dag is running [airflow]
wolfier opened a new issue, #54927:
URL: https://github.com/apache/airflow/issues/54927
### 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](https://airflow.apache.org/docs/apache-airflow/2.11.0/authoring-and-scheduling/deferring.html) 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:
1. Create a dag with a deferrable TI and start a dagrun
2. Wait for the TI to enter the deferred state
3. Pause the dag
4. Check the task logs
The same behaviour can be reproduced for deactivated dags
1. Create a dag with a deferrable TI and start a dagrun
2. Wait for the TI to enter the deferred state
3. Remove the dag from the dags folder
4. Confirm dag is deactivate and the TI is deferred
5. Check the task logs
I used the `DateTimeSensorAsync` (`apache-airflow-providers-standard==1.6.0`) sensor to demostrate the behaviour.
```python
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?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Triggers of a task instance that belongs to a deactivated / paused dag is running [airflow]
Posted by "suhail-zemoso (via GitHub)" <gi...@apache.org>.
suhail-zemoso commented on issue #54927:
URL: https://github.com/apache/airflow/issues/54927#issuecomment-3250219620
Ignore the background noise in the video. As you can see, when I triggered the video, the task instance went into the deferred state. Then, I paused the DAG, and during that time no logs were generated. When I unpaused the DAG, the triggers were reassigned to the triggerer, and it ran until it fired. According to me, this is the expected behavior. Please verify if I am on the right track
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Triggers of a task instance that belongs to a deactivated / paused dag is running [airflow]
Posted by "suhail-zemoso (via GitHub)" <gi...@apache.org>.
suhail-zemoso commented on issue #54927:
URL: https://github.com/apache/airflow/issues/54927#issuecomment-3242842304
## Proposed Solution
@wolfier Watch the recording to verify the expected behaviour
https://www.loom.com/share/c3c874834ee7478a89f3639dd23df445?sid=4c2f4648-3221-4207-844a-3a3509550224
### Problem Analysis
- **Current Behavior**:
- Triggers continue running even when their DAG is paused or deactivated
- No clear distinction between paused and deactivated DAGs in trigger handling
- No mechanism to resume triggers after a DAG is unpaused
- **Impact**:
- Unnecessary resource usage from running triggers for inactive DAGs
- Inconsistent behavior between UI actions (pause/unpause) and actual trigger execution
- Potential for unwanted task execution when DAGs are in an inactive state
### Solution Implementation
1. **For Paused DAGs**:
- Triggers are unassigned from the current triggerer but kept in the database
- Task instances remain in `DEFERRED` state with their `trigger_id` preserved
- Triggers are reassigned when the DAG is unpaused
- Added comprehensive logging for better traceability
2. **For Deactivated DAGs**:
- Triggers are permanently deleted from the database
- Associated task instances are marked as `FAILED`
- Prevents any further trigger execution for deactivated DAGs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Triggers of a task instance that belongs to a deactivated / paused dag is running [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on issue #54927:
URL: https://github.com/apache/airflow/issues/54927#issuecomment-3986440032
@suhail-zemoso We are unassigning you from this issue as part of our updated [assignment policy](https://github.com/apache/airflow/blob/main/contributing-docs/04_how_to_contribute.rst#contribute-code-changes).
This is not meant to discourage your contribution — quite the opposite! You are still very welcome to work on this issue and submit a PR for it. Simply comment that you are working on it and open a PR when ready.
We found that formal assignments were not working well, as they often prevented others from contributing when the assignee was not actively working on the issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Triggers of a task instance that belongs to a deactivated / paused dag is running [airflow]
Posted by "suhail-zemoso (via GitHub)" <gi...@apache.org>.
suhail-zemoso commented on issue #54927:
URL: https://github.com/apache/airflow/issues/54927#issuecomment-3222445932
I will work on this issue---Let me know if its being picked by someone else.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Triggers of a task instance that belongs to a deactivated / paused dag is running [airflow]
Posted by "wolfier (via GitHub)" <gi...@apache.org>.
wolfier commented on issue #54927:
URL: https://github.com/apache/airflow/issues/54927#issuecomment-3250112128
I am unable to recognize what is being said in the video. While the video does show that a deferred task instance works when the dagrun is in the running state, it does not follow through the rest of the reproduction steps.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Triggers of a task instance that belongs to a deactivated / paused dag is running [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on issue #54927:
URL: https://github.com/apache/airflow/issues/54927#issuecomment-3223709138
Feel free.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org