This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch v2-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 6866a7c2e131b5e8fcbef5473abd4835cad1c972
Author: Ephraim Anierobi <splendidzig...@gmail.com>
AuthorDate: Tue Aug 17 09:37:56 2021 +0100

    Fix wrong query on running tis (#17631)
    
    Fix wrong query on my PR about deleting running dags #17630
    
    Co-authored-by: Kaxil Naik <kaxiln...@gmail.com>
    (cherry picked from commit 84df8646ba396088e70ca8469b301d11d13d2da7)
---
 airflow/api/common/experimental/delete_dag.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/airflow/api/common/experimental/delete_dag.py 
b/airflow/api/common/experimental/delete_dag.py
index eb45384..44e54e3 100644
--- a/airflow/api/common/experimental/delete_dag.py
+++ b/airflow/api/common/experimental/delete_dag.py
@@ -42,7 +42,10 @@ def delete_dag(dag_id: str, keep_records_in_log: bool = 
True, session=None) -> i
     """
     log.info("Deleting DAG: %s", dag_id)
     running_tis = (
-        
session.query(models.TaskInstance.state).filter(models.TaskInstance.state.in_(State.unfinished)).all()
+        session.query(models.TaskInstance.state)
+        .filter(models.TaskInstance.dag_id == dag_id)
+        .filter(models.TaskInstance.state == State.RUNNING)
+        .first()
     )
     if running_tis:
         raise AirflowException("TaskInstances still running")

Reply via email to