Repository navigation
fix(io): bound the rate-limited keep-pin grace, then spend one re-resolve (#380) - #381
Conversation
…olve (superuser404notfound#380) A pause of a few minutes, then resume, froze VOD playback for ~60 s on a connection-capped panel: the pinned post-redirect URL answered 509 to 20 consecutive generations (~85 s) while a fresh redirect through the source connected in 452 ms. Three coupled defects kept the reader grinding the dead pin until the segment layer tore the producer down from outside: - The keep-pin rule for rate-limit statuses (8a8e00b, superuser404notfound#307 follow-up) had no bound. It models the lingering slot, which frees in seconds; a pinned edge session that expired during a long idle answers 509 forever, and only a re-resolve heals it. The pin now survives rateLimitRepinStreak (3) paced attempts and is then dropped for exactly one re-resolve; the fresh target's 200/206 re-pins. Both ladders share the rung, and the hard-error rung is unchanged. - The window-serve branch reset both streaks on every served read, in the same iteration as the faulted-refill decision, so every attempt against the refusing origin was charged streak=1 while the runway drained, and one served byte after an exhaustion restarted the whole ladder. The streaks now reset only when the current generation has delivered data (connFirstDataSeen). - startPersistentConnection reset nextFaultedRefillAt as part of the very reconnect the charge had just authorised, so the announced pacing never held and attempts ran on read cadence. The timestamp now survives the reconnect and is released by first data or a seek - the give-up latch actually latches now too. Test plan: swift test on macOS 26 (1867 tests green). New cases in the resolved-URL suite: a stale-lease origin (source mints per-request lease URLs, dead leases 509 forever) heals with exactly one source resolve at grace+1 attempts, and a paced consumer draining 2 MB of runway keeps the ladder charged (bounded at 7 boundary attempts, read fails only after serving every pre-boundary byte). Both verified failing on the unfixed base (20 unbounded attempts; read died without healing). The two-attempt lingering-slot cases (503 and 509 keep the pin) stay green unchanged; the permanent-509 case now expects the bounded re-resolve inside the same seven attempts. Field shape from an Apple TV 4K (tvOS 26) against an Xtream aggregator with max_connections=1 whose edge host expires idle sessions. Co-Authored-By: Claude Opus 4.8 <[email protected]>
d35d078
into
superuser404notfound:main
|
Merged as d35d078. Thank you for this one: a report that arrives with the mechanism, the two smaller defects that turn the policy gap into the full freeze, and a loopback rig that reproduces it is about as good as it gets. Two things worth adding to the record. Independent corroboration from #377, filed the same weekA different reporter, a different origin, 429 rather than 509, and mid-playback rather than post-pause. Their trace after retesting the #377 branch: 45 s of refusals against the pin, then 210 ms once a fresh demuxer's reader re-resolved. That is your 452 ms, on someone else's CDN. Their pinned host also changes between sessions, so those are per-session signed targets expiring on their own schedule, which is the shape your grace bound is written for. They reached your issue on their own and asked whether it was their root cause seen from the other end. It reads like it is. What I pulled in afterwards (#386)Reviewing the PR against main turned up that the read loop serves from memory in three places, and your fix covers one of them.
Also dropped the
Verified on the merge with main (your branch was 12 commits behind, and the #377 budget lands in the same file): 1886 tests, 273 suites, green. |
Fixes #380.
What
A pause of a few minutes, then resume, froze VOD playback for ~60 s on a connection-capped
panel: the pinned post-redirect URL answered 509 to 20 consecutive generations (~85 s) while a
fresh redirect through the source connected in 452 ms. Three coupled defects kept the reader
grinding the dead pin until the segment layer tore the producer down from outside — the full
trace and analysis are in the issue.
How
8a8e00b0) modelsthe lingering slot, which frees in seconds — and for that shape nothing changes: the pin
survives
rateLimitRepinStreak(3) paced attempts, which is the existing two-attempt tests'territory plus margin. A rate-limited streak that reaches the rung is the other shape (a
pinned edge session that expired during a long idle and refuses forever), and there the pin
is dropped for exactly one re-resolve through the source; the fresh target's 200/206 re-pins.
Both ladders (
chargeFaultedRunwayRefilland the empty-window path) share the rung; thehard-error rung (
unproductiveReconnects >= 2) is unchanged.progress: the reset ran in the same read iteration as the faulted-refill decision, so every
attempt against the refusing origin was charged streak=1 while the runway drained, the
bounded give-up and the new rung were unreachable, and one served byte after an exhaustion
restarted the whole ladder. The streaks now reset only when the current generation has
delivered data (
connFirstDataSeen, already winCond-guarded in that branch).startPersistentConnectionresetnextFaultedRefillAtas part of starting the very attemptthe charge had just paced, so "next attempt in Ns" never held and attempts ran on read
cadence. The reset moved to the two events that genuinely end a faulted lineage: first data
(
appendPersistentData) and an intentional reposition (seekReconnect). The.distantFuturegive-up latch actually latches now, and first data re-arms it for a later, unrelated fault.
Test plan
swift teston macOS 26: 1867 tests green.ResolvedURLInvalidationTests(both verified failing on the unfixed base):rig where the source mints per-request lease URLs and the CDN 509s dead leases forever.
Fixed: heals at
rateLimitRepinStreak + 1boundary attempts with exactly one post-faultsource resolve. Unfixed base: 7 attempts, zero resolves, read dies at the boundary.
draining 2 MB of runway against a permanent 509. Fixed: bounded at ≤ 7 boundary attempts,
every pre-boundary byte served, then a clean −1. Unfixed base: 20 attempts.
bounded re-resolve (≥ 1, ≤ 4 source hits) inside the same seven attempts.
end), the hard-500 fallback,
ErrorEndedReconnectTests,Issue309SilentTransportDeathTests(including the parked-is-not-stalled regression), the live-window suites, and the detour cap
unit test.
max_connections=1) whoseedge host expires idle sessions; device retest against that origin planned as soon as a
release with this lands on the app's pin.
🤖 Generated with Claude Code