Repository navigation
fix(node): read the 0x10 RATE_LIMITED close requester-side instead of scoring Unreachable - #1993
Merged
Merged
Conversation
… scoring Unreachable A node that sheds load at the transport closes the connection (or resets the stream) with APP_ERR_RATE_LIMITED and a layer label, and waits 250 ms so the peer sees it. The requester never read it: client-pull flattened every transport error to a string, so node_origin's probe_candidate and pull_verdict fell through to Outcome::Unreachable — a 0.0 EWMA sample for a peer that answered, and one every prober in a global-full window recorded at once. The handler-level shed (Overloaded → signed NotFound) was already exonerated as RefusalVerdict::Transient; the two layers disagreed on the same condition. client-pull gains `UpstreamRateLimited`, a typed sentinel, and `rate_limit_shed`, which walks an error's source chain for an ApplicationClosed / ReadError::Reset / WriteError::Stopped carrying the code (including through FrameError::Io's io::Error, whose inner stream error is reachable only via get_ref). Every connect / open_bi / write_frame / read_frame site in probe.rs and lib.rs routes through it; plain messages are unchanged. node_origin treats the sentinel exactly like the handler-level shed: the (peer, hash) pair is suppressed for REFUSAL_SUPPRESSION_TTL, a new `decdn_node_upstream_rate_limited_total` counter ticks, and no reputation outcome is recorded. New PullVerdict::RateLimited folds to PullMiss::Clean. ADR 013's 0x10 row names the consumer. A global-full shed still skips the node's close ack-wait and can arrive as a bare drop; that residue keeps scoring Unreachable. Closes #1986 Co-Authored-By: Claude Opus 5 <[email protected]>
Coverage reportTotal: 82.69% (was 82.68%, ▲ +0.01%) — 76653/92697 lines
History
|
APP_ERR_RATE_LIMITED is only sent before any application stream exists (ADR 013 §Application Error Codes), so route only the open-stage transport calls — connect, open_bi, the initial request write, and read_stream_response — through transport_error. The two mid-delivery helpers, write_message (vouchers) and read_client_message, keep plain error text: typing a shed there would trust the "0x10 only pre-stream" invariant rather than scope the recovery to where the limiters can actually fire, and would let a peer dodge the Unreachable score by resetting a stream 0x10 mid-delivery. Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.
Closes #1986.
Problem
A node that sheds load at the transport closes the connection (or resets the stream) with
APP_ERR_RATE_LIMITED(0x10) and a layer label — and waits 250 ms so the peer sees it. The requester never read it:client-pullflattened every transport error toanyhow!("open_bi failed: {e}"), sonode_origin'sprobe_candidateandpull_verdictfell through toOutcome::Unreachable— a 0.0 EWMA sample for a peer that answered, and one every prober in aglobal-fullwindow recorded simultaneously. The handler-level shed (Overloaded→ signedNotFound) was already exonerated asRefusalVerdict::Transient; the two layers disagreed on the same condition.Fix (issue's option 1)
decdn-client-pull: newrate_limitedmodule —UpstreamRateLimited { label }sentinel andrate_limit_shed, which walks an error'ssource()chain for anApplicationClosed/ReadError::Reset/WriteError::Stoppedcarrying0x10, including throughFrameError::Io'sio::Error(whose inner stream error is reachable only viaget_ref(), notsource()). Everyconnect/open_bi/write_frame/read_framesite inprobe.rsandlib.rsroutes throughtransport_error; every existing message string is unchanged.node_origin: the sentinel gets exactly what the handler-level shed gets — the(peer, hash)pair is suppressed forREFUSAL_SUPPRESSION_TTL(30 s), noOutcomeis recorded.probe_candidatechecks it before theUnreachablefallback;pull_verdictmaps it to a newPullVerdict::RateLimited(→PullMiss::Clean).decdn_node_upstream_rate_limited_total, the only trace the event leaves at the defaultRUST_LOG=info.0x10row names the requester-side consumer.Tests
rate_limitedunit tests: label carried off a connection close,Nonefor a stream reset, non-0x10codes ignored, recovery throughFrameError → io::Error → ReadError/WriteErrornesting, anddowncast_refthrough added context.node_originunit tests:pull_verdict→RateLimitedthrough context layers,PullMiss::Clean, sentinel added to the downcast-survival and every-verdict enumerations.probe_loopback:probe_onceagainst a pre-drained per-sourceConnectionLimiterreturnsUpstreamRateLimited { label: Some("per-source") }(bounded retry over the flaky: probe_rate_limit_returns_rate_limited_close_code races on the application close code (sees 0 instead of 16) #1594 close-frame race, same as the sibling test).Accepted residue
A
global-fullshed deliberately skips the node's close ack-wait (probe.rs— a flood would park a task per rejection), so it can still arrive as a bare drop and scoreUnreachable. The metric doc calls this out. DHT emitters need no consumer: the DHT client records no reputation.Out of scope, not changed:
decdn fetchstill counts a rate-limited probe under "unreachable" in its terminal message (fetch.rsdrops the error withres.ok()) — cosmetic, follow-up.🤖 Generated with Claude Code