-
-
Notifications
You must be signed in to change notification settings - Fork 710
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
Fix P2P worker cleanup #7981
Merged
Merged
Fix P2P worker cleanup #7981
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c70b4cb
Rename and use teardown
hendrikmakait 9790360
Renaming
hendrikmakait 25a5cc3
Test shutdown
hendrikmakait 593fa02
Check for teardown
hendrikmakait f4b5f1c
Fix tests
hendrikmakait e0d0174
Fix tests
hendrikmakait f83bc40
Fix check
hendrikmakait 74599ee
Merge branch 'main' into shuffle-shutdown
hendrikmakait File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
from dask.utils import parse_bytes | ||
|
||
from distributed.core import PooledRPCCall | ||
from distributed.diagnostics.plugin import WorkerPlugin | ||
from distributed.exceptions import Reschedule | ||
from distributed.protocol import to_serialize | ||
from distributed.shuffle._arrow import ( | ||
|
@@ -552,7 +553,7 @@ | |
return self.worker_for[id] | ||
|
||
|
||
class ShuffleWorkerExtension: | ||
class ShuffleWorkerPlugin(WorkerPlugin): | ||
"""Interface between a Worker and a Shuffle. | ||
|
||
This extension is responsible for | ||
|
@@ -571,7 +572,7 @@ | |
memory_limiter_disk: ResourceLimiter | ||
closed: bool | ||
|
||
def __init__(self, worker: Worker) -> None: | ||
def setup(self, worker: Worker) -> None: | ||
# Attach to worker | ||
worker.handlers["shuffle_receive"] = self.shuffle_receive | ||
worker.handlers["shuffle_inputs_done"] = self.shuffle_inputs_done | ||
|
@@ -588,10 +589,10 @@ | |
self._executor = ThreadPoolExecutor(self.worker.state.nthreads) | ||
|
||
def __str__(self) -> str: | ||
return f"ShuffleWorkerExtension on {self.worker.address}" | ||
return f"ShuffleWorkerPlugin on {self.worker.address}" | ||
|
||
def __repr__(self) -> str: | ||
return f"<ShuffleWorkerExtension, worker={self.worker.address_safe!r}, closed={self.closed}>" | ||
return f"<ShuffleWorkerPlugin, worker={self.worker.address_safe!r}, closed={self.closed}>" | ||
|
||
# Handlers | ||
########## | ||
|
@@ -638,7 +639,7 @@ | |
exception = RuntimeError(message) | ||
shuffle.fail(exception) | ||
|
||
async def _(extension: ShuffleWorkerExtension, shuffle: ShuffleRun) -> None: | ||
async def _(extension: ShuffleWorkerPlugin, shuffle: ShuffleRun) -> None: | ||
await shuffle.close() | ||
extension._runs.remove(shuffle) | ||
|
||
|
@@ -805,7 +806,7 @@ | |
existing.fail(RuntimeError("Stale Shuffle")) | ||
|
||
async def _( | ||
extension: ShuffleWorkerExtension, shuffle: ShuffleRun | ||
extension: ShuffleWorkerPlugin, shuffle: ShuffleRun | ||
) -> None: | ||
await shuffle.close() | ||
extension._runs.remove(shuffle) | ||
|
@@ -855,7 +856,7 @@ | |
self._runs.add(shuffle) | ||
return shuffle | ||
|
||
async def close(self) -> None: | ||
async def teardown(self, worker: Worker) -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Along with this so that the worker plugin now conforms to the |
||
assert not self.closed | ||
|
||
self.closed = True | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is the magic that ensures things are cleaned up, because the client will teardown the scheduler which tears down all the worker plugins?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And pretty much everything else is downstream renaming changes....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty much, yes. IIUC, extensions don't get cleaned up at all. Worker plugins will get torn down on worker close, but for that the method has to be called
teardown
(as seen below). Similarly, we need to move some of the initialization tosetup
.