Repository navigation
fix(tokio): escalate the backoff when GOAWAY redirects loop between peers - #6162
Conversation
…eers Mirrors #6115: while migrations are chained, a redirect back to an endpoint that already sent the client elsewhere skips the healthy-session reset, so the backoff escalates to its cap and the retry window ends the loop with a redirect-loop error. Brent's cycle detection keeps the state constant, endpoints compare without their query or fragment, and a session that outlived the capped delay starts a new run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 33 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a43b27e1da
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| fn endpoint(url: &Url) -> Url { | ||
| let mut bare = url.clone(); | ||
| bare.set_query(None); | ||
| bare.set_fragment(None); | ||
| bare |
There was a problem hiding this comment.
Strip non-dial credentials from redirect endpoint keys
For host-based transports, this retains URL userinfo and path even though userinfo is ignored by dialing and paths may carry rotating credentials. A bouncing pair can therefore return redirects such as tcp://token-N@peer/ on every healthy session; each key remains unique, Redirects::depart never detects the revisit, and the retry timeout keeps resetting, recreating the unbounded redirect loop this change is intended to stop. Build the comparison key from the actual transport endpoint (scheme, host, and effective port), preserving the path only for hostless transports such as Unix sockets.
AGENTS.md reference: AGENTS.md:L18-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Userinfo: fixed in 259e604. It never reaches a dial, so endpoint now strips it along with the query and fragment, and the test covers it.
Path: kept, as in JS (moq-dev/moq#6115). For host-based transports the path is the request target (the WebTransport request, or the SETUP path for moqt/moql/tcp/tls), so relay/a and relay/b are different requests rather than credentials. A hostile peer that wants to dodge detection can already rotate ports under the default same-host policy, so no key catches every evasion. What bounds such a peer is that each hop needs a session outliving backoff.initial. Loop detection is there for fleets that bounce clients by accident, not as a bound on hostile peers.
(Written by Claude Opus 5.5)
Userinfo never reaches a dial, so a peer rotating it could hide a loop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review (Written by Claude Opus 5.5) |
1 similar comment
|
@codex review (Written by Claude Opus 5.5) |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
# Conflicts: # quest/m1/README.md
Completes quest/m1/tokio-redirect-loop.md, mirroring moq-dev/moq#6115 in Rust.
Problem
moq-tokio's reconnect loop only damped a GOAWAY redirect that arrived withinbackoff.initialof connecting. Two relays that each redirect the client to the other after a session outlives that delay bounce it between them forever: every hop scores as healthy,Retry::settleresets the delay and the retry window, and no error is ever reported.Approach (same rule as JS)
Redirects). A redirect back to one of them skips the healthy-session reset, so the delay escalates tobackoff.maxandbackoff.timeoutstill ends the run, with the errorredirect loop(the JS name). The redirect itself is still honoured.backoff.max(it already redials no faster than the backoff would).Tests
redirect_loop_detection_catches_any_cycle_in_constant_memoryandan_endpoint_ignores_the_credentials: pure unit tests, ported from JS.tests/integration/reconnect.rs: two relays ping-ponging (with and without rotating credentials) escalate through the jittered backoff; a loop ends at the retry window withredirect loop; a loop no faster than the cap, a one-way rolling restart, and same-place GOAWAYs (named and empty) never back off. Those last cases use a retry window shorter than a session's life, so a wrongly scored hop ends the connection deterministically instead of relying on an upper time bound.These run on the wall clock with lower bounds, not on tokio's paused clock as the quest suggested. Real moq-tokio sessions over TCP or Unix sockets aren't transparent to a paused clock: virtual time jumps by seconds while the runtime waits on socket I/O.
rs/AGENTS.mdallows wall-clock tests with lower bounds for real sockets. The four loop tests take about 5s in total.Impact
Backoffdoc comments change to describe the loop behaviour.backoff.max, now waits out the jittered backoff and counts againstbackoff.timeout, which can end the connection withredirect loop. The draining session keeps serving during that wait, up to its handover cap.Verification
just check: passes.(Written by Claude Opus 5.5)
🤖 Generated with Claude Code