fix(router): make HTTPConnector and NIXLConnector stateless to prevent data races and request corruption - #1657
Open
bhuvan-somisetty wants to merge 1 commit into
Conversation
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
bhuvan-somisetty
force-pushed
the
fix/stateless-connectors-data-race-1656
branch
from
August 20, 2026 12:58
945c71f to
c210031
Compare
HTTPConnector and NIXLConnector stored mutable per-request state (prefillRequest, decodeRequest, and decodeRequestBody) as fields on the connector structs. In PD disaggregation mode, connector singletons are shared across concurrent requests, leading to data races and request cross-talk under concurrency where one request's decode payload would be overwritten by another concurrent request. Make HTTPConnector and NIXLConnector stateless by maintaining prefill and decode request objects as local variables within Proxy, and add concurrent regression tests verifying thread safety. Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>
bhuvan-somisetty
force-pushed
the
fix/stateless-connectors-data-race-1656
branch
from
August 23, 2026 00:24
c210031 to
d5427f5
Compare
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.
What type of PR is this?
/kind bug
What this PR does / why we need it:
In
HTTPConnector(pkg/kthena-router/connectors/http.go) andNIXLConnector(pkg/kthena-router/connectors/nixl.go), mutable per-request state (prefillRequest,decodeRequest, anddecodeRequestBody) were maintained as struct fields on the connector instances.When Kthena Router operates in PD disaggregation mode, connector singletons created via
r.connectorFactory.GetConnector(connectorType)are shared across concurrent requests. When two or more requests are routed throughHTTPConnector,NIXLConnector, orMoonCakeConnectorconcurrently, multiple goroutines concurrently mutate and readh.decodeRequest,h.prefillRequest,n.prefillRequest, andn.decodeRequestBodyon the shared connector instance without synchronization. This causes a data race and request payload corruption, where one request's decode phase sends another concurrent request's prompt and parameters to the decode engine.This PR makes
HTTPConnectorandNIXLConnectorcompletely stateless by:prefillRequest,decodeRequest,decodeRequestBody) fromHTTPConnectorandNIXLConnector.Proxy()and passing them directly intoprefill()anddecode().TestHTTPConnector_ConcurrentThreadSafetyandTestNIXLConnector_ConcurrentThreadSafety) that simulate concurrent requests through a shared connector instance to verify thread safety and payload isolation.Which issue(s) this PR fixes:
Fixes #1656
Bug evidence (required for bug-related PRs):
Production execution path:
proxyToPDDisaggregatedobtains the connector singleton from factory:https://github.com/volcano-sh/kthena/blob/713a4a5814526d19b45781a742ea3521d9657065/pkg/kthena-router/router/router.go#L1363
HTTPConnector.Proxywrites to struct fieldsh.decodeRequestandh.prefillRequest:https://github.com/volcano-sh/kthena/blob/713a4a5814526d19b45781a742ea3521d9657065/pkg/kthena-router/connectors/http.go#L74-L77
NIXLConnector.Proxywrites to struct fieldsn.prefillRequestandn.decodeRequestBody:https://github.com/volcano-sh/kthena/blob/713a4a5814526d19b45781a742ea3521d9657065/pkg/kthena-router/connectors/nixl.go#L65-L67
decodeRequest/decodeRequestBody.Verified by concurrent regression unit tests running concurrent goroutines through shared connector instances.
Special notes for your reviewer:
All unit tests in
pkg/kthena-router/...pass cleanly.Does this PR introduce a user-facing change?: