Repository navigation
fix(orchestrator): keep router session releases working after a burst - #4408
Merged
Merged
Conversation
A burst of releases on the shared 4-connection admin pool hits an httpcore 1.0.9 race that leaves connections CONNECTING forever, so every later release failed silently at DEBUG. Releases now use their own 32-connection client behind a matching semaphore, replace the client on a pool timeout, log failures as a warning and report cumulative released/failed counts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a burst Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kept in history at bbd2d3b for verification. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
garrett361
marked this pull request as ready for review
November 6, 2026 02:22
mikasenghaas
approved these changes
Nov 6, 2026
hallerite
approved these changes
Nov 6, 2026
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.
This PR gives the orchestrator's router-session releases their own HTTP client and caps how many run at once. Before, a burst of releases could leave the shared client permanently unable to send any request, so releases silently stopped for the rest of the run. From then on the router treated every finished rollout as still running, and placed new rollouts on inference replicas based on that wrong picture of their load.
Background. With the
sticky_least_loadedrouter policy, each rollout is a session pinned to one inference replica so later turns reuse its prefix cache. The router places each new session on the replica holding the fewest sessions. When an episode ends, the orchestrator calls/finish_sessionso the router stops counting it. If a release never arrives, the router keeps counting the session until its time to live (TTL) expires, 2 h by default.Bug 1: a burst loses most of its releases. All releases shared one httpx client with 4 connections, a 10 s wait per attempt for a free connection, and errors logged at DEBUG. When many episodes end at once (for example, a sandbox outage failing thousands of episodes), thousands of releases queue for those 4 connections:
Most time out waiting, which loses those releases. On its own this is temporary: once the burst drains, releases work again.
Bug 2: those timeouts permanently break the client. httpcore 1.0.9 (the latest release) has a race in exactly that timeout. It is reported upstream in encode/httpcore#1099 (open, unmerged), where a comment reproduces this pool-timeout case on the same versions; the pydantic fork fixed it in pydantic/httpx2#983.
The pool opens a new connection instead of reusing the one that just finished because the old client kept at most 1 idle connection, and httpcore 1.0.9 counts every connection, busy or idle, against that limit. So with 4 connections open, each one is closed the moment it frees up.
Thousands of requests time out at nearly the same moment, so this fires reliably and each occurrence costs one slot for good:
A fresh client works immediately, which is how the reproducer confirms the pool, not the router, is at fault.
Consequence. The router keeps treating finished sessions as active until its TTL removes them. It sends each new session to the replica with the fewest sessions, so a replica holding many finished ones looks busier than it is and receives less new work, while a replica holding few receives more. The session counts look even across replicas, but the actual work is not. If the table reaches
VLLM_ROUTER_SLL_MAX_SESSIONS(100,000 by default), new sessions are no longer pinned to one replica and lose their prefix cache on every turn (we have not hit this; the largest table we have seen peaked at about a third of the limit). Training data and rewards are unaffected; this is purely a routing-efficiency problem, and it was invisible because nothing was logged above DEBUG.The fix. A release now needs one of 32 tickets (a semaphore) before it sends anything, and the release client has exactly 32 connections. Releases that find no free ticket wait in
clients.py, not inside httpx, so httpx's pool wait and its race never come into play:PoolTimeoutcan then only mean a leaked connection, so the release path replaces the client and the next releases go out on a fresh one.sessions/released/sessions/release_failedreport cumulative counts.CONNECTINGIDLETrade-offs a reviewer should know:
AdminPlane) and the Dynamo frontend's startup checks. Each sends only a few requests at a time, so none ever waits for a connection.Verification
Commit bbd2d3b adds
tools/repro_session_release_pool_leak.pyand the next commit removes it, so it stays in this PR's history without landing onmain. It copies the old and new release paths, runs them against a local/finish_sessionserver through the dispatcher's cancellation pattern, and prints delivery, follow-up releases and pool state per burst. It runs anywhere, without the repo's dependencies:--server-delay 0.01 --episodes 3000 --bursts 1gives the first table row;new --undersized-poolgives the pool 4 connections for 32 tickets, so its connections leak and the client replacement path recovers it.🤖 Generated with Claude Code