|
5 | 5 |
|
6 | 6 | from distributed.protocol.serialize import Serialize |
7 | 7 | from distributed.utils import recursive_to_dict |
8 | | -from distributed.utils_test import _LockedCommPool, assert_story, gen_cluster, inc |
| 8 | +from distributed.utils_test import ( |
| 9 | + _LockedCommPool, |
| 10 | + assert_story, |
| 11 | + freeze_data_fetching, |
| 12 | + gen_cluster, |
| 13 | + inc, |
| 14 | +) |
9 | 15 | from distributed.worker_state_machine import ( |
10 | 16 | ExecuteFailureEvent, |
11 | 17 | ExecuteSuccessEvent, |
@@ -348,3 +354,31 @@ async def test_in_memory_while_in_flight(c, s, a, b): |
348 | 354 | # Let the comm from b to a return the result |
349 | 355 | event.set() |
350 | 356 | assert await y == 4 # Data in flight from b has been discarded |
| 357 | + |
| 358 | + |
| 359 | +@gen_cluster(client=True) |
| 360 | +async def test_forget_data_needed(c, s, a, b): |
| 361 | + """ |
| 362 | + 1. A task transitions to fetch and is added to data_needed |
| 363 | + 2. _ensure_communicating runs, but the network is saturated so the task is not |
| 364 | + popped from data_needed |
| 365 | + 3. Task is forgotten |
| 366 | + 4. Task is recreated from scratch and transitioned to fetch again |
| 367 | + 5. BUG: at the moment of writing this test, data_needed.push silently did nothing, |
| 368 | + because it still contained the forgotten task, which is a different TaskState |
| 369 | + instance which will be no longer updated. |
| 370 | + 6. _ensure_communicating runs. It pops the forgotten task and discards it. |
| 371 | + 7. We now have a task stuck in fetch state. |
| 372 | + """ |
| 373 | + x = c.submit(inc, 1, key="x", workers=[a.address]) |
| 374 | + with freeze_data_fetching(b): |
| 375 | + y = c.submit(inc, x, key="y", workers=[b.address]) |
| 376 | + await wait_for_state("x", "fetch", b) |
| 377 | + x.release() |
| 378 | + y.release() |
| 379 | + while s.tasks or a.tasks or b.tasks: |
| 380 | + await asyncio.sleep(0.01) |
| 381 | + |
| 382 | + x = c.submit(inc, 2, key="x", workers=[a.address]) |
| 383 | + y = c.submit(inc, x, key="y", workers=[b.address]) |
| 384 | + assert await y == 4 |
0 commit comments