Repository navigation
[Router] Pin the backpressure disposition at the dispatch sites - #40218
Draft
Kangyan-Zhou wants to merge 1 commit into
Draft
Kangyan-Zhou wants to merge 1 commit into
Kangyan-Zhou wants to merge 1 commit into
Conversation
The end-to-end tests asserted only that a 503 leaves the breaker Closed, which `record_success` satisfies identically — so swapping `record_backpressure` for `record_success` in both dispatch arms passed the entire suite. The property that makes Neutral a third verb rather than an alias for success is that it does NOT reset an in-progress failure streak, and that was covered on the breaker alone, never through dispatch. Drive the streak across a backpressure answer instead: a scripted worker serves fault, fault, backpressure, fault against an explicit threshold of 3, and the final fault must still open the breaker. Added for the JSON arm, for 429 as well as 503 (the streaming/JSON arms act on `breaker_outcome`, but only 503 had ever been exercised end to end), and for the streaming arm, which records on a separate code path. Each of the three fails if the dispatch site records backpressure as success. Also cover two states that were documented but untested: backpressure arriving while the breaker is already Open must neither untrip it nor restart its cool-down, and the streaming arm must resolve a half-open probe answered with 503 — the JSON arm had that guard, the streaming arm did not. Fix the unresolved `record_success` intra-doc link in the same docstring. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wt25p6zfdw6QFLguPRsj82
Kangyan-Zhou
marked this pull request as draft
September 18, 2026 18:24
This branch has not been deployed
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.
Motivation
Follow-up to #39464 (merged as
4e0b56c8), which taught the circuit breakerto treat an upstream 503/429 as backpressure rather than a fault.
That PR's end-to-end tests asserted only that a 503 leaves the breaker Closed.
record_successsatisfies that identically — so the dispatch-site wiring wasnot actually pinned. Verified by mutation on the merged commit: replacing
BreakerOutcome::Neutral => breaker.record_backpressure()withrecord_success()in both dispatch arms passed the entire suite, all 918tests, undetected.
The property that makes
Neutrala third verb rather than an alias for successis that it does not reset an in-progress failure streak — "a worker
interleaving genuine 5xx faults with 503s still trips". That was covered on the
breaker alone (
backpressure_in_closed_state_preserves_failure_streak), neverthrough
forward_json_to/forward_streaming_to.Modifications
Tests only — no behaviour change.
A scripted mock worker.
spawn_scripted_workerserves a sequence ofstatuses, repeating the last. A fixed-status worker structurally cannot express
the interleaving that separates the two verbs.
Three tests that fail if a dispatch site records backpressure as success.
Each drives fault, fault, backpressure, fault against an explicit
threshold of 3 and asserts the final fault still opens the breaker:
engine_503_does_not_reset_an_in_progress_failure_streakengine_429_does_not_reset_an_in_progress_failure_streakengine_503_does_not_reset_an_in_progress_failure_streak_streamingThe threshold is pinned via
STREAK_THRESHOLDrather than inherited fromCircuitBreakerConfig::default(), because these assert on an exact streaklength — a change to the default must not silently move the trip point.
Two documented-but-untested states.
backpressure_while_open_does_not_reset_the_breaker—record_backpressure'sOpen arm is justified at length in its docstring and had no coverage. Asserts
a late 503 neither untrips the breaker nor restarts its cool-down.
engine_503_recovers_a_half_open_breaker_streaming— the JSON arm had ahalf-open wedge guard; the streaming arm did not, and the probe can just as
easily land there.
Also fixes the unresolved
[`record_success`]intra-doc link in the samedocstring (
Self::-qualified, matching its siblings).Tests
cargo testgreen — 730 lib, 7 bin, 65 component, 121 proxy.cargo clippy --all-targets -- -D warningsclean;pre-commitclean.Mutation-checked in both directions: green as committed, and with
record_backpressure→record_successre-applied at both dispatch sitesexactly the three streak tests fail.
Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_01Wt25p6zfdw6QFLguPRsj82
CI States
Latest PR Test (Base): ✅ Run #35379854356
Latest PR Test (Extra): ❌ Run #35379854013
Latest PR Test (AMD ROCm 10): ➖ No AMD PR run found for this commit.