canyang25 commented on code in PR #74213:
URL: https://github.com/apache/airflow/pull/74213#discussion_r4242178585


##########
airflow-core/tests/unit/models/test_dagrun.py:
##########
@@ -396,6 +396,56 @@ def test_dagrun_deadlock(self, dag_maker, session):
         dr.update_state(session=session)
         assert dr.state == DagRunState.FAILED
 
+    @pytest.mark.parametrize(
+        "limit_kwargs",
+        [
+            pytest.param({"max_active_tis_per_dag": 1}, 
id="max_active_tis_per_dag"),
+            pytest.param({"max_active_tis_per_dagrun": 1}, 
id="max_active_tis_per_dagrun"),
+        ],
+    )
+    def test_deleted_ti_deadlocks_run_despite_concurrency_limit(self, 
dag_maker, session, limit_kwargs):
+        with dag_maker(schedule=datetime.timedelta(days=1), session=session):
+            upstream = EmptyOperator(task_id="upstream")
+            downstream = EmptyOperator(task_id="downstream", **limit_kwargs)
+            downstream.set_upstream(upstream)
+
+        dr = dag_maker.create_dagrun()
+        upstream_ti = dr.get_task_instance(task_id=upstream.task_id, 
session=session)
+        downstream_ti = dr.get_task_instance(task_id=downstream.task_id, 
session=session)
+        upstream_ti.set_state(state=TaskInstanceState.SUCCESS, session=session)
+        downstream_ti.set_state(state=None, session=session)
+        session.flush()
+
+        dr.update_state(session=session)
+        assert dr.state == DagRunState.RUNNING
+
+        session.delete(upstream_ti)
+        session.flush()
+        session.expire_all()
+
+        dr.update_state(session=session)
+        assert dr.state == DagRunState.FAILED
+
+    def test_concurrency_limit_does_not_deadlock_a_runnable_task(self, 
dag_maker, session):

Review Comment:
   thanks @fat-catTW  Parametrized 
test_concurrency_limit_does_not_deadlock_a_runnable_task over both 
max_active_tis_per_dag and max_active_tis_per_dagrun; both pass.



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