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

Fix canceling inflight messages for which requests are closed #803

Merged
merged 2 commits into from
Oct 28, 2021
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
12 changes: 6 additions & 6 deletions ucp/_libs/ucx_endpoint.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ cdef void _cancel_inflight_msgs(UCXWorker worker, set inflight_msgs):
cdef dict req_info
cdef str name
for req in list(inflight_msgs):
assert not req.closed()
req_info = <dict>req._handle.info
name = req_info["name"]
logger.debug("Future cancelling: %s" % name)
# Notice, `request_cancel()` evoke the send/recv callback functions
worker.request_cancel(req)
if not req.closed():
req_info = <dict>req._handle.info
name = req_info["name"]
logger.debug("Future cancelling: %s" % name)
# Notice, `request_cancel()` evoke the send/recv callback functions
worker.request_cancel(req)


class UCXEndpointCloseCallback():
Expand Down
13 changes: 7 additions & 6 deletions ucp/_libs/ucx_worker.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -277,16 +277,17 @@ cdef class UCXWorker(UCXObject):
ucp_worker_print_info(self._handle, text_fd)
return decode_text_fd(text_fd)

def query_total_inflight_messages_to_cancel(self):
"""Query the total of inflight messages scheduled to cancel
def cancel_inflight_messages(self):
"""Cancel inflight messages scheduled for canceling

While there are messages scheduled for canceling, we need to progress
the worker. Therefore, this can be used to query if there are still any
such messages and progress while the result is larger than 0.
If any messages are scheduled for canceling, we need to trigger their
cancelation and return the number of canceled messages, if there are
any messages to cancel, the worker needs to progress to complete the
cancelation.

Returns
-------
total: The total number of inflight messages scheduled to cancel.
total: The total number of inflight messages canceled.
"""
len_inflight_msgs_to_cancel = len(self._inflight_msgs_to_cancel)
if len_inflight_msgs_to_cancel > 0:
Expand Down
2 changes: 1 addition & 1 deletion ucp/continuous_ucx_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async def _arm_worker(self):
# Cancel inflight messages that couldn't be completed. This may
# happen if the user called ep.recv() but the remote worker
# errored before sending the message.
if worker.query_total_inflight_messages_to_cancel() > 0:
if worker.cancel_inflight_messages() > 0:
worker.progress()

del worker
Expand Down