uranusjr commented on a change in pull request #17631:
URL: https://github.com/apache/airflow/pull/17631#discussion_r689412666



##########
File path: 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()

Review comment:
       Ash mentioned `exists()` would be more (most, I think) performant 
https://github.com/apache/airflow/pull/17630#discussion_r689343499
   
   But if you don’t want to deal with the MSSQL caveat, `count()` is probably 
the next best.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to