[Bug] Fix possible race condition in HCCL handshake#266
Conversation
There was a problem hiding this comment.
Code Review
This pull request addresses a race condition in the HCCL handshake timeout (Github issue #263) by waiting for the handshake ready event before retrieving the connection handle. The feedback suggests handling the case where the handshake event is None explicitly and raising a more idiomatic ConnectionError instead of a KeyError when the connection handle is missing.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Marco Barletta <65128997+marcobarlo@users.noreply.github.com>
There was a problem hiding this comment.
maybe 120s is a bit too long tho, wdyt @chloroethylene
Summary
This PR fixes issue #263.
HcclMemRegRequestcan runbefore the background
accept()thread publishesconn_handles_dict[peer_id].HcclErrorResponse; prefiller crashes withAttributeError: 'HcclErrorResponse' object has no attribute 'server_mem_handle_bytes'. PD transfer fails; proxy hangs on KV-ready.HcclChannel._handle_init_msgMemReg path only(
lmcache_ascend/v1/transfer_channel/hccl_channel.py).Why
HcclInitRequest, the server startscomplete_handshake()(backgroundaccept()), waits only foraccept_started_event, then replies Init.connect()and send MemReg before T3 writes the handle.HcclReadyRequestalready waits on_peer_ready_events; MemReg did not.ready_event(timeout 120s) before looking upconn_handles_dict, and raise clearly if the handle is still missing.Test plan
KeyError/ init-loop failure before“Connection established”.
server_mem_handle_bytes; KV transfercompletes and proxy returns successfully.
Notes
lazy_init_peer_connection, T2_init_loop→_handle_init_msg, T3 nestedcomplete_handshake.