Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions distributed/tests/test_stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from dask import delayed

from distributed import Client, Nanny, wait
from distributed.chaos import KillWorker
from distributed.compatibility import WINDOWS
from distributed.config import config
from distributed.metrics import time
Expand Down Expand Up @@ -284,3 +285,29 @@ async def test_no_delay_during_large_transfer(c, s, w):
nbytes -= nbytes[0]
assert nbytes.max() < (x_nbytes * 2) / 1e6
assert nbytes[-1] < (x_nbytes * 1.2) / 1e6


@pytest.mark.slow
@gen_cluster(client=True, Worker=Nanny, nthreads=[("127.0.0.1", 2)] * 6)
async def test_chaos_rechunk(c, s, *workers):
s.allowed_failures = 10000

plugin = KillWorker(delay="4 s", mode="graceful")

await c.register_worker_plugin(plugin, name="kill")

da = pytest.importorskip("dask.array")

x = da.random.random((10000, 10000))
y = x.rechunk((10000, 20)).rechunk((20, 10000)).sum()
z = c.compute(y)

start = time()
while time() < start + 10:
if z.status == "error":
await z
if z.status == "finished":
return
await asyncio.sleep(0.1)

await z.cancel()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What does this actually test? Every 4 seconds, all workers will shut down, losing all accrued progress, and will be start being restarted in chain by the nannies. Over time, timings will drift apart and reach a somewhat random distribution of restarts. It's close to impossible to reach z.status=="finished", as it would take way more than 4s to finish (it takes 13s without KillWorker on a speedy laptop). Because of the very high allowed_failures, status should never be failed. If the cluster deadlocks e.g. due to illegal transitions, the test won't notice.

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.

See #6134

15 changes: 10 additions & 5 deletions distributed/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2541,12 +2541,14 @@ def _transition(
instructions += b_instructions
except InvalidTransition:
raise InvalidTransition(
f"Impossible transition from {start} to {finish} for {ts.key}"
) from None
f"Impossible transition from {start} to {finish} for {ts.key}",
self.story(ts),
)

else:
raise InvalidTransition(
f"Impossible transition from {start} to {finish} for {ts.key}"
f"Impossible transition from {start} to {finish} for {ts.key}",
self.story(ts),
)

self.log.append(
Expand Down Expand Up @@ -3044,7 +3046,7 @@ async def gather_dep(
for d in has_what:
ts = self.tasks[d]
ts.who_has.remove(worker)
if not ts.who_has:
if not ts.who_has and ts.state not in ("released", "memory"):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I see the failure in https://github.com/dask/distributed/runs/6032728170?check_suite_focus=true

            assert all(
                dep.key in self.data or dep.key in self.actors
                for dep in ts.dependencies
            )

but I'm not following why relaxing this from ts.state in ("fetch", "flight") caused it. I accept that it seems to work, but I'd like to understand it.

If you'd be willing to add an assert ts.state in ("fetch", "flight"), ts.state within this current conditional, I'd be very curious to see what fails in CI. I can't really make sense of why we'd want to transition tasks in any other state to missing.

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.

I'd like to understand it.

I encourage you to understand it :)

If you'd be willing to add an assert ts.state in ("fetch", "flight"), ts.state within this current conditional, I'd be very curious to see what fails in CI

I think that we should do this in another PR and get this in as it is. I'd like to resolve this deadlock and get out a release.

recommendations[ts] = "missing"
self.log.append(
("missing-who-has", worker, ts.key, stimulus_id, time())
Expand Down Expand Up @@ -3089,7 +3091,10 @@ async def gather_dep(
self.batched_stream.send(
{"op": "missing-data", "errant_worker": worker, "key": d}
)
recommendations[ts] = "fetch" if ts.who_has else "missing"
if ts.who_has:
recommendations[ts] = "fetch"
elif ts.state not in ("released", "memory"):
recommendations[ts] = "missing"
Comment on lines +3094 to +3097

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could the task be in memory or missing even if who_has is non empty?

Guess I'm wondering why this isn't:

Suggested change
if ts.who_has:
recommendations[ts] = "fetch"
elif ts.state not in ("released", "memory"):
recommendations[ts] = "missing"
if ts.state not in ("released", "memory"):
recommendations[ts] = "fetch" if ts.who_has else "missing"

For that matter, could ts be errored? If ts was stolen to this worker (and executed) in the time since the gather_dep started, and execution failed? What about other terminal states?

I feel like an passlist here (likely fetch/flight) still would make more sense. If some action has occurred in the meantime since gather_dep started which has changed the task's state to something non-dependency-fetch-y, that probably takes precedence over re-fetching it right? I'd be curious if/why an passlist doesn't work.

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.

I'm happy to make a change like what is above because it seems safe relative to what is here already.

When I implemented the allowlist / passlist tests failed, so our reasoning here is not yet correct. I think that we should absolutely pursue this, but that we should handle that separately. I'd like to get this in for a release and I don't want to increase scope much beyond "avoid released/memory -> missing transitions". I totally get that we might want to do more eventually, but I don't think that we need to do more in order to do this.

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.

I'm happy to make a change like what is above because it seems safe relative to what is here already.

Wait, no, it looks like that would exclude more paths. I'm really looking for a minimal set of changes that avoid the deadlock for right now.

del data, response
self.transitions(recommendations, stimulus_id=stimulus_id)

Expand Down