renzepost commented on code in PR #49752:
URL: https://github.com/apache/airflow/pull/49752#discussion_r2065998349


##########
airflow-core/src/airflow/api/common/mark_tasks.py:
##########
@@ -215,17 +215,30 @@ def set_dag_run_state_to_success(
     if not run_id:
         raise ValueError(f"Invalid dag_run_id: {run_id}")
 
-    # Mark all task instances of the dag run to success - except for teardown 
as they need to complete work.
+    # Mark all task instances of the dag run to success - except for 
unfinished teardown as they need to complete work.
     normal_tasks = [task for task in dag.tasks if not task.is_teardown]
+    teardown_tasks = [task for task in dag.tasks if task.is_teardown]
+    unfinished_teardown_tis: list[TaskInstance] = session.scalars(
+        select(TaskInstance).where(
+            TaskInstance.dag_id == dag.dag_id,
+            TaskInstance.run_id == run_id,
+            TaskInstance.task_id.in_([task.task_id for task in 
teardown_tasks]),
+            or_(TaskInstance.state.is_(None), 
TaskInstance.state.in_(State.unfinished)),
+        )
+    ).all()

Review Comment:
   Done! Thanks for the feedback.



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