Repository navigation
shm_broadcast: bind XPUB port atomically to avoid pinned-port race - #1
Closed
charlotte12l wants to merge 1 commit into
Closed
charlotte12l wants to merge 1 commit into
charlotte12l wants to merge 1 commit into
Conversation
When SGLANG_PORT is pinned and multiple MessageQueue writers start concurrently on the same node, get_open_port() followed by a later bind() is a non-atomic check-then-bind: two writers can be handed the same port and then collide on bind() with EADDRINUSE. The loser dies, drops its gloo peer, and cascades into "connection reset by peer" on the next collective. Replace get_open_port()+bind() with zmq's bind_to_random_port, which picks and binds a free port atomically. When SGLANG_PORT is set the search starts at that base (min=base, max=base+8) to preserve the existing port range; otherwise it falls back to the default ephemeral range. A similar atomic fix is proposed upstream in sgl-project#15885 (PR sgl-project#15903). Signed-off-by: xingyuliu <xingyuliu@fb.com>
Owner
Author
|
Retargeting to upstream sgl-project/sglang. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
When
SGLANG_PORTis pinned and multipleMessageQueuewriters startconcurrently on the same node, the XPUB local socket setup uses
get_open_port()followed by a laterbind()— a non-atomiccheck-then-bind. Two writers can be handed the same port and then collide
on
bind()withEADDRINUSE.One scheduler subprocess dies at init:
which then cascades into a gloo failure on every rank:
This replaces
get_open_port()+bind()with zmq'sbind_to_random_port,which picks and binds a free port atomically. When
SGLANG_PORTis set thesearch starts at that base (
min=base,max=base + 8) to preserve theexisting port range; otherwise it falls back to the default ephemeral range.
A similar atomic fix is proposed upstream in sgl-project#15885 (PR sgl-project#15903).
Test
Concurrent
MessageQueuewriters under a pinnedSGLANG_PORTno longerhit the
EADDRINUSEerror; each binds a distinct port.CI States
Latest PR Test (Base): ❌ Run #28311918658
Latest PR Test (Extra): ❌ Run #28311918565