Skip to content

Raise exceptions in Server.handle_stream instead of swallowing/logging. - #7162

Merged
fjetter merged 14 commits into
dask:mainfrom
hendrikmakait:improve-handle_stream-logs
Nov 3, 2022
Merged

fjetter merged 14 commits into
dask:mainfrom
hendrikmakait:improve-handle_stream-logs

Conversation

@hendrikmakait

@hendrikmakait hendrikmakait commented Oct 20, 2022 •

Copy link
Copy Markdown
Member

When closing the stream handler, it would be helpful to understand the reason instead of stopping silently.

In particular, we should not swallow an OSError silently when it may lead to the comm being closed.

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

@github-actions

github-actions Bot commented Oct 20, 2022 •

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.

       15 files  ±0         15 suites  ±0   6h 26m 36s ⏱️ - 19m 14s
  3 166 tests ±0    3 079 ✔️  - 2    83 💤 ±0  4 ❌ +2 
23 424 runs  ±0  22 521 ✔️ +3  899 💤  - 3  4 ❌ ±0 

For more details on these failures, see this check.

Results for commit 5871722. ± Comparison against base commit a573da0.

♻️ This comment has been updated with latest results.

@hendrikmakait
hendrikmakait marked this pull request as draft October 20, 2022 08:02
@hendrikmakait
hendrikmakait marked this pull request as ready for review October 20, 2022 10:04
@hendrikmakait hendrikmakait self-assigned this Oct 20, 2022
Comment thread distributed/core.py Outdated
Comment on lines +834 to +837
logger.info(
"Received 'close-stream' from %s; closing.",
comm.peer_address,
)

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.

This is a bit verbose, isn't it?

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.

close-stream should only occur in a few instances, I would like to be able to see when those happen.

Comment thread distributed/core.py Resolved
@hendrikmakait

Copy link
Copy Markdown
Member Author

After an offline discussion with @fjetter, we decided that handle_stream should raise all exceptions and leave handling them to the caller.

@hendrikmakait hendrikmakait changed the title Log exception on OSError in Server.handle_stream. Raise exceptions in Server.handle_stream instead of swallowing/logging. Oct 24, 2022
@hendrikmakait
hendrikmakait marked this pull request as draft October 24, 2022 16:27
@hendrikmakait
hendrikmakait marked this pull request as ready for review October 25, 2022 18:38
@hendrikmakait
hendrikmakait requested a review from fjetter October 26, 2022 13:33
Comment thread distributed/worker.py Resolved
Comment thread distributed/scheduler.py Resolved
@hendrikmakait
hendrikmakait requested a review from fjetter November 1, 2022 16:04
@hendrikmakait
hendrikmakait marked this pull request as draft November 2, 2022 10:04
Comment thread distributed/core.py
try:
msgs = await comm.read()
# If another coroutine has closed the comm, stop handling the stream.
except CommClosedError:

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.

As discussed offline with @fjetter, we should use the CommClosedError as a stopping and synchronization mechanism between coroutines that are dealing with the comm. If one of them decides to close the comm, the CommClosedError allows us to propagate that without race conditions.

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.

FWIW It's not ideal but I believe this is how it was intended at some point. We may need to revise this but that would be a bigger change that is feasible right now.

@hendrikmakait
hendrikmakait marked this pull request as ready for review November 2, 2022 12:12
@fjetter
fjetter merged commit de371f5 into dask:main Nov 3, 2022
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.

2 participants