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:21:02 UTC

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

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



##########
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),

Review comment:
       ```suggestion
               TaskInstance.state == TaskInstanceState.running,
   ```

##########
File path: airflow/api/common/experimental/mark_tasks.py
##########
@@ -70,7 +71,7 @@ def set_state(
     past: bool = False,
     state: TaskInstanceState = TaskInstanceState.SUCCESS,
     commit: bool = False,
-    session=None,
+    session: SASession = None,

Review comment:
       Please search for `session: Session = NEW_SESSION` for a more idomatic way to annotate this.




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