Skip to content

Fix deadlock in P2P restarts - #8091

Merged
fjetter merged 2 commits into
dask:mainfrom
hendrikmakait:fix-p2p-deadlock
Aug 10, 2023
Merged

fjetter merged 2 commits into
dask:mainfrom
hendrikmakait:fix-p2p-deadlock

Conversation

@hendrikmakait

Copy link
Copy Markdown
Member

Closes #8088

  • Tests added / passed
  • Passes pre-commit run --all-files

@github-actions

github-actions Bot commented Aug 9, 2023 •

Copy link
Copy Markdown
Contributor

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

       20 files  +       1         20 suites  +1   11h 22m 11s ⏱️ + 18m 44s
  3 764 tests  -        1    3 656 ✔️ +       7     106 💤  -     2  2 ❌  - 6 
36 412 runs  +3 628  34 658 ✔️ +3 534  1 751 💤 +101  3 ❌  - 7 

For more details on these failures, see this check.

Results for commit 65fdcc4. ± Comparison against base commit 9469b91.

This pull request removes 2 and adds 1 tests. Note that renamed tests count towards both.
distributed.cli.tests.test_dask_worker.test_listen_address_ipv6[tcp:..[ ‑ 1]:---nanny]
distributed.cli.tests.test_dask_worker.test_listen_address_ipv6[tcp:..[ ‑ 1]:---no-nanny]
distributed.shuffle.tests.test_shuffle ‑ test_restarting_does_not_deadlock

♻️ This comment has been updated with latest results.

Comment thread distributed/scheduler.py

return {}, {}, {}
recommendations: Recs = {}
self._propagate_released(ts, recommendations)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing a dedicated test for this is harder than anticipated. I think we might catch most (all?) non-P2P edge cases in other places. FWIW, removing this from transition_queued_released only fails P2P as well.

@fjetter fjetter Aug 10, 2023 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this kind of test is triggering this transition

@gen_cluster(nthreads=[("", 1)] * 2, client=True)
async def test_no_worker_released(c, s, a, b):
    f1 = c.submit(inc, 1, workers=[a.address], allow_other_workers=True, key='f1')
    f2 = c.submit(inc, f1, resources={"C": 1}, key='f2')

    while not f2.key in s.tasks or s.tasks[f2.key].state != "no-worker":
        await asyncio.sleep(0.01)

    assert f1.key in a.data and not f1.key in b.data
    await a.close()
    ...

In this test, f2 is in no-worker and then transitioned to released. The reason why this hasn't caused any issues so far is because in this example, the transition is no-worker->released->waiting

The scheduler extension is however expecting two transitions

  • whatever->released
  • released->waiting->processing

i.e. the scheduler extension issues a transition to released and is relying on the recommendation system to trigger appropriate follow ups. All other ordinary transitions rather transition immediately to waiting

So, another fix could be to make the shuffle extension smarter and more aware about what the intended target state is. However, I believe that defeats the purpose of the transition engine and this fix is fine. (this ambiguity was/is also a common problem in the worker)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this test, f2 is in no-worker and then transitioned to released. The reason why this hasn't caused any issues so far is because in this example, the transition is no-worker->released->waiting

That's what I meant, sorry. It's hard to write a dedicated test that fails on main but isn't using P2P for the reason you described above.

So, another fix could be to make the shuffle extension smarter and more aware about what the intended target state is. However, I believe that defeats the purpose of the transition engine and this fix is fine. (this ambiguity was/is also a common problem in the worker)

+1, I think it's better to have the reconciliation logic within the state machine instead of forcing all users of the state machine to handle those edge cases.

@hendrikmakait
hendrikmakait marked this pull request as ready for review August 10, 2023 09:29
@hendrikmakait
hendrikmakait requested a review from fjetter as a code owner August 10, 2023 09:29
Comment thread distributed/scheduler.py

return {}, {}, {}
recommendations: Recs = {}
self._propagate_released(ts, recommendations)

@fjetter fjetter Aug 10, 2023 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this kind of test is triggering this transition

@gen_cluster(nthreads=[("", 1)] * 2, client=True)
async def test_no_worker_released(c, s, a, b):
    f1 = c.submit(inc, 1, workers=[a.address], allow_other_workers=True, key='f1')
    f2 = c.submit(inc, f1, resources={"C": 1}, key='f2')

    while not f2.key in s.tasks or s.tasks[f2.key].state != "no-worker":
        await asyncio.sleep(0.01)

    assert f1.key in a.data and not f1.key in b.data
    await a.close()
    ...

In this test, f2 is in no-worker and then transitioned to released. The reason why this hasn't caused any issues so far is because in this example, the transition is no-worker->released->waiting

The scheduler extension is however expecting two transitions

  • whatever->released
  • released->waiting->processing

i.e. the scheduler extension issues a transition to released and is relying on the recommendation system to trigger appropriate follow ups. All other ordinary transitions rather transition immediately to waiting

So, another fix could be to make the shuffle extension smarter and more aware about what the intended target state is. However, I believe that defeats the purpose of the transition engine and this fix is fine. (this ambiguity was/is also a common problem in the worker)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

P2P shuffle restart may deadlock if no running workers exist

2 participants