Skip to content
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

Better logging for anomalous task termination #8082

Merged
merged 2 commits into from
Aug 8, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 13 additions & 11 deletions distributed/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5165,17 +5165,19 @@ def test_quiet_client_close(loop):
sleep(0.200) # stop part-way
sleep(0.1) # let things settle

out = logger.getvalue()
lines = out.strip().split("\n")
assert len(lines) <= 2
for line in lines:
assert (
not line
or "heartbeat from unregistered worker" in line
or "unaware of this worker" in line
or "garbage" in line
or set(line) == {"-"}
), line
out = logger.getvalue()
lines = out.strip().split("\n")
unexpected_lines = [
line
for line in lines
if line
and "heartbeat from unregistered worker" not in line
and "unaware of this worker" not in line
and "garbage" not in line
and "ended with CancelledError" not in line
and set(line) != {"-"}
]
assert not unexpected_lines, lines


@pytest.mark.slow
Expand Down
4 changes: 3 additions & 1 deletion distributed/worker_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -3656,9 +3656,11 @@ def _finish_async_instruction(
stim = task.result()
except asyncio.CancelledError:
# This should exclusively happen in Worker.close()
logger.warning(f"Async instruction for {task} ended with CancelledError")
return
except BaseException: # pragma: nocover
logger.exception("async instruction handlers should never raise!")
# This should never happen
logger.exception(f"Unhandled exception in async instruction for {task}")
Copy link
Member

Choose a reason for hiding this comment

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

Not intended as blocking comment, but I could see it being useful if we included the type of the exception and possibly the exception message here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

logger.exception automatically does that

raise

# Capture metric events in _transition_to_memory()
Expand Down