fat-catTW commented on code in PR #74213:
URL: https://github.com/apache/airflow/pull/74213#discussion_r4241819903
##########
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 for the fix.
One small nit: could we also cover the non-deadlock case for
`max_active_tis_per_dagrun`?
The deleted-TI regression test is already parametrized for both
`max_active_tis_per_dag` and `max_active_tis_per_dagrun`, but
`test_concurrency_limit_does_not_deadlock_a_runnable_task` currently only
exercises `max_active_tis_per_dag`. Since the production change removes both
guards from `should_schedule`, it would be good to have the safety/counter-case
covered for both as well.
--
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]