Skip to content

Commit 03035da

Browse files
Fix deadlock (#8703)
1 parent ac3854e commit 03035da

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

distributed/scheduler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2540,7 +2540,7 @@ def _transition_memory_released(self, key: Key, stimulus_id: str) -> RecsMsgs:
25402540
recommendations[key] = "waiting"
25412541

25422542
for dts in ts.waiters or ():
2543-
if dts.state in ("no-worker", "processing"):
2543+
if dts.state in ("no-worker", "processing", "queued"):
25442544
recommendations[dts.key] = "waiting"
25452545
elif dts.state == "waiting":
25462546
if not dts.waiting_on:

distributed/tests/test_scheduler.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4650,6 +4650,43 @@ def assert_rootish():
46504650
await c.gather(fut3)
46514651

46524652

4653+
@gen_cluster(client=True, nthreads=[("", 1)])
4654+
async def test_deadlock_dependency_of_queued_released(c, s, a):
4655+
@delayed
4656+
def inc(input):
4657+
return input + 1
4658+
4659+
@delayed
4660+
def block_on_event(input, block, executing):
4661+
executing.set()
4662+
block.wait()
4663+
return input
4664+
4665+
block = Event()
4666+
executing = Event()
4667+
4668+
dep = inc(0)
4669+
futs = [
4670+
block_on_event(dep, block, executing, dask_key_name=("rootish", i))
4671+
for i in range(s.total_nthreads * 2 + 1)
4672+
]
4673+
del dep
4674+
futs = c.compute(futs)
4675+
await executing.wait()
4676+
assert s.queued
4677+
await s.remove_worker(address=a.address, stimulus_id="test")
4678+
4679+
s.validate_state()
4680+
4681+
await block.set()
4682+
await executing.clear()
4683+
4684+
async with Worker(s.address) as b:
4685+
s.validate_state()
4686+
await c.gather(*futs)
4687+
s.validate_state()
4688+
4689+
46534690
@gen_cluster(client=True)
46544691
async def test_submit_dependency_of_erred_task(c, s, a, b):
46554692
x = c.submit(lambda: 1 / 0, key="x")

0 commit comments

Comments
 (0)