Repository navigation
Keep a failover route down until a probe's connection stays open - #86
Conversation
A connect-and-close probe brought a route back as soon as anything accepted. On Fabric that is docker-proxy on the fallback route's published port, which accepts before Harper binds and closes when its dial is refused, so every new connection in that window was dropped with route error `stream`. - The probe sends nothing and needs the connection to stay open for 250 ms. - Only the probe clears a slot; a client connect no longer does. - A reload of a down route starts the endpoints it did not have as refusing, since fresh health reads as up and an unmarked slot is never probed. - Health transitions are read from the live table after a probe pass. Refs #84 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Dispatch-Task: symphony-84-failback-readiness
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Dispatch-Task: symphony-84-failback-readiness
Pins that a peer writing continuously cannot hold a probe past its deadline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Dispatch-Task: symphony-84-failback-readiness
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Dispatch-Task: symphony-84-failback-readiness
There was a problem hiding this comment.
Code Review
This pull request modifies the health-checking and failover probing mechanism to handle upstreams that accept connections before they are actually ready to serve (such as Docker's userland proxy). Specifically, a successful client connection no longer clears a slot's refused status; instead, only the background probe can clear it, and only if the connection remains open for at least 250 milliseconds. Additionally, when a down route is reloaded, any new endpoints it did not previously have are initialized as refusing until they are verified by a probe. Extensive tests and documentation updates have been added to support these changes. I have no feedback to provide as there are no review comments to assess.
⊙ Problem
After a local Harper restart, a failover route can report up about 1 s before Harper serves. New connections in that window drop with route error
stream. Docker accepts them, not Harper. While Harper's socket metadata is missing, host-manager points the route at a published port, where docker-proxy accepts before Harper binds. symphony's probe counts that accept as recovery. After a crash, the reload onto that port brings the route up with no probe.💡 Solution
⚖️ Alternatives
🤔 Why fix this here if the fleet is turning off Docker's userland proxy?
userland-proxy: falseis the primary fix: a published port then refuses until Harper binds, and the existing forward covers every case. This PR keepsrouteHealthandlocalUptruthful until that ships, and behind any other proxy. Once it is everywhere, Fabric no longer depends on this probe.🤔 Is requiring upstreams to hold an idle connection for 250 ms acceptable?
A failover upstream that closes an idle connection sooner never clears once marked, so its traffic stays on peers. Harper holds one for 10 s. Failover is opt-in, and Fabric is its only known user.
🤔 Should a route with no mark stay exposed?
Yes, until the fleet change: connections in the window still fail. Marking on a
streamerror would fix this, but the copying code cannot tell a client's reset from an upstream's, so a client could take a route down.🔧 Changes
How a restart reaches the window
docker-proxy accepts first and dials the container second, so it accepts for as long as Harper is booting.
sequenceDiagram participant HM as host-manager participant S as symphony participant P as docker-proxy participant H as Harper Note over H: sockets gone HM->>S: reload: route is now TCP passthrough Note over P: binds when the container starts S->>P: probe connects P->>H: dial H-->>P: refused P-->>S: closes Note over S: before: up. now: stays down Note over H: binds after components load S->>P: probe connects, stays open 250 ms Note over S: up HM->>S: reload: route is UDS againuserland-proxy: falseFiles
src/failover.rs:stays_openreads to the 250 ms deadline, andprobeuses it. Health transitions now come from the live table, so a probe of a replaced endpoint cannot report its replacement up.src/upstream.rs: a TCP connect and a Unix socket connect can only mark a slot, asconnect's doc says.src/router.rs:previous_downreaches the Unix socket slots and the TCP health.src/balancer.rs:with_healthstarts a new slot refusing throughSlotHealth::new.README.md: the probe, the upstream contract and the unmarked-route limit.CLAUDE.md: the invariants, the probe pass bound and the test map.ts/types.ts: theprobeIntervalMsdoc.✅ Verification
updateConfigflip. 5 fail on base; the other 3 guard behavior that must not change.npm testpasses 267 of 267,cargo testpasses 242 with 1 ignored, andcargo clippy --all-targetsandcargo fmt --checkare clean.macos-14runner, also on a retry.ss -ltnp 'sport = :9936'during a restart would confirm the accepter.Performance: a client connect does less: one relaxed load and, on a marked slot, one compare-and-swap are gone. Everything added runs on the probe task or at reload. A probe pass can take up to
ceil(endpoints / 64) x 1.25 s.How the accepter was identified
ECONNREFUSED, then served. No connection accepted and then closed, and one socket inode per bootlistenOnPorts<loopback>:9936, a Docker publishdaemon.jsonuserland-proxy, whose default istruetcp_proxy_linux.goAccept, thenDialTCP, thenclient.Close()on a failed dialstream,localUp: true,refusingSlots: 0routeHealth upat the reloadThe socket files' modification times were later than the first drops in the stage run because no Unix socket was in the path yet.
Test cases
Fail on base, pass here:
streamerrors.routeHealth up, then back to the Unix socket.Pass on base and here:
Rust: a connect to a marked slot leaves it marked, probe outcomes (close, reset, silent, a banner, an answer and close, a late close, a peer that keeps writing), and which endpoints a reload marks.
Refs Don't route to a restarted upstream until it serves, not just accepts.
🤖 Generated by Claude Code (Claude Opus 5.5); posted via @kriszyp.
Related PRs: #85 overlaps, 2 others independent
Complexity: medium
Origin — the dispatch brief this PR was written from
Don't route to a restarted upstream until it serves, not just accepts
CONSULT FIRST: investigate, then open a needs-input consultation with your findings and proposed fix before implementing. Issue #84: when a local Harper restarts, symphony's failover probe (connect-and-close, src/failover.rs probe) clears the route's down mark about 1 s before Harper serves on its per-thread Unix socket, and connections in that window are accepted then closed with no response (route error 'stream', 4-7 ms). Find out what accepts during that window and decide where the fix belongs (Harper binding/accepting before it can serve, a symphony probe/hold-down change, or both), then implement the agreed symphony part and open a draft PR. If the root fix is in Harper, say so and draft a HarperFast/harper issue body in the consultation rather than changing Harper from this task.
Acceptance
Dispatch: task
symphony-84-failback-readiness· queued by kris-session · ran by claude/opus/xhigh · worker kzyp-xps-1Review-Coverage: authored=claude; ran=cursor-composer,codex,gemini,cursor-grok; late=cursor-grok:adjudicated; adjudicated=domain; declined=muse; rounds=4; full=2 @ 18b1596
Review-Attention: read ~4m @ 18b1596