tanelk commented on code in PR #23143:
URL: https://github.com/apache/airflow/pull/23143#discussion_r854910413
##########
tests/jobs/test_scheduler_job.py:
##########
@@ -1135,6 +1135,42 @@ def
test_find_executable_task_instances_not_enough_task_concurrency_for_first(se
session.rollback()
+ def test_find_executable_task_instances_negative_open_pool_slots(self,
dag_maker):
+ """
+ Pools with negative open slots should not block other pools.
+ Negative open slots can happen when reducing the number of total slots
in a pool
+ while tasks are running in that pool.
+ """
+ set_default_pool_slots(0)
+
+ self.scheduler_job = SchedulerJob(subdir=os.devnull)
+ session = settings.Session()
+
+ pool1 = Pool(pool='pool1', slots=1)
+ pool2 = Pool(pool='pool2', slots=1)
+
+ session.add(pool1)
+ session.add(pool2)
+
+ dag_id =
'SchedulerJobTest.test_find_executable_task_instances_negative_open_pool_slots'
+ with dag_maker(dag_id=dag_id):
+ op1 = EmptyOperator(task_id='op1', pool='pool1')
+ op2 = EmptyOperator(task_id='op2', pool='pool2', pool_slots=2)
+
+ dr1 = dag_maker.create_dagrun(run_type=DagRunType.SCHEDULED)
+
+ ti1 = dr1.get_task_instance(op1.task_id, session)
+ ti2 = dr1.get_task_instance(op2.task_id, session)
+ ti1.state = State.SCHEDULED
+ ti2.state = State.RUNNING
+ session.flush()
+
+ res =
self.scheduler_job._executable_task_instances_to_queued(max_tis=1,
session=session)
+ assert 1 == len(res)
+ assert res[0].key == ti1.key
Review Comment:
Without this fix no tasks are queued here
--
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]