Fix panic in SGLang proxy handling of concurrent requests#632
Open
yangligt2 wants to merge 2 commits intollm-d:mainfrom
Open
Fix panic in SGLang proxy handling of concurrent requests#632yangligt2 wants to merge 2 commits intollm-d:mainfrom
yangligt2 wants to merge 2 commits intollm-d:mainfrom
Conversation
|
🚨 Unsigned commits detected! Please sign your commits. For instructions on how to set up GPG/SSH signing and verify your commits, please see GitHub Documentation. |
7c2324a to
0ff5b6e
Compare
Signed-off-by: YANG LI <yangligt@google.com>
0ff5b6e to
f469e35
Compare
Author
|
cc: @bongwoobak |
bongwoobak
reviewed
Feb 18, 2026
Signed-off-by: YANG LI <yangligt@google.com>
c9e9525 to
13833f4
Compare
bongwoobak
approved these changes
Feb 18, 2026
Collaborator
|
/lgtm |
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.
Fix #631
Description
This PR addresses a critical connection termination bug where the
pd-sidecarpanics withnet/http: abort Handlerunder concurrent load (concurrency > 1) when running with the SGLang connector.Root Cause:
In the SGLang architecture, the sidecar splits incoming requests and submits them to both the prefill and decode backends concurrently. The decode pipeline runs synchronously, while the prefill pipeline is dispatched asynchronously in a background goroutine.
Both requests were previously inheriting the identical request context using
r.Clone(r.Context()). Because the prefill200 OKresponse stream frequently arrives after the decode processing has successfully completed and returned, the standard Go HTTP server automatically cancels the parent contextr.Context().When this cancellation occurs before the background prefill proxy has fully read its response stream,
httputil.ReverseProxyinterprets it as an aborted connection and fatals withhttp.ErrAbortHandler, bringing down the sidecar pod.As seen in the sidecar debug logs under load, the prefill request completions (
prefill request completed) log significantly later than the target forwarding:Fix:
This PR properly unties the background prefill context lifecycle from the main synchronous request using
context.WithoutCancel. Adefer recover()was additionally added to the async call stack for extra safety against uncaught internal proxy panics propagating to the main service loop. Added aTestSGLangGinkgo test suite to validate end-to-end functionality.Validation
Validated in a real GKE environment with SGLang backends:
concurrency=512.go test -v -run SGLangtests cleanly pass.