Skip to content

Restart worker if it's unrecognized by scheduler #6505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2022
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
22 changes: 22 additions & 0 deletions distributed/tests/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1783,6 +1783,28 @@ async def close(self):
assert not s.workers


@gen_cluster(
client=True,
nthreads=[("", 1)],
Worker=Nanny,
worker_kwargs={"heartbeat_interval": "1ms"},
)
async def test_heartbeat_missing_restarts(c, s: Scheduler, n: Nanny):
Copy link
Member

Choose a reason for hiding this comment

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

nit: Emphasize that we test for the status missing, not a heartbeat that went missing.

Suggested change
async def test_heartbeat_missing_restarts(c, s: Scheduler, n: Nanny):
async def test_heartbeat_status_missing_restarts(c, s: Scheduler, n: Nanny):

old_heartbeat_handler = s.handlers["heartbeat_worker"]
s.handlers["heartbeat_worker"] = lambda *args, **kwargs: {"status": "missing"}

assert n.process
await n.process.stopped.wait()

assert not s.workers
s.handlers["heartbeat_worker"] = old_heartbeat_handler

await n.process.running.wait()
assert n.status == Status.running

await c.wait_for_workers(1)


@gen_cluster(nthreads=[])
async def test_bad_local_directory(s):
try:
Expand Down
3 changes: 2 additions & 1 deletion distributed/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,8 @@ async def heartbeat(self):
logger.error(
f"Scheduler was unaware of this worker {self.address!r}. Shutting down."
)
await self.close()
# Something is out of sync; have the nanny restart us if possible.
await self.close(nanny=False)
return

self.scheduler_delay = response["time"] - middle
Expand Down