You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/01/04 09:50:47 UTC

[GitHub] [airflow] dungdm93 commented on a change in pull request #20649: bugfix: deferred tasks does not cancel when DAG is marked fail

dungdm93 commented on a change in pull request #20649:
URL: https://github.com/apache/airflow/pull/20649#discussion_r777950197



##########
File path: airflow/api/common/experimental/mark_tasks.py
##########
@@ -335,18 +336,18 @@ def set_dag_run_state_to_failed(dag, execution_date, commit=False, session=None)
 
     # Mark the dag run to failed.
     if commit:
-        _set_dag_run_state(dag.dag_id, execution_date, State.FAILED, session)
+        _set_dag_run_state(dag.dag_id, execution_date, TaskInstanceState.FAILED, session)
 
-    # Mark only RUNNING task instances.
+    # Mark only running task instances.
     task_ids = [task.task_id for task in dag.tasks]
     tis = (
         session.query(TaskInstance)
         .filter(
             TaskInstance.dag_id == dag.dag_id,
             TaskInstance.execution_date == execution_date,
             TaskInstance.task_id.in_(task_ids),
+            TaskInstance.state.in_(State.running),
         )
-        .filter(TaskInstance.state == State.RUNNING)
     )

Review comment:
       Yes. That's right.




-- 
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