Skip to content

fix(task): corroborate a refused connect by the peers it overlapped - #217

Draft
greenhat616 wants to merge 1 commit into
feat/hardening-47-adaptive-windowfrom
fix/hardening-48-hung-connect-evidence
Draft

greenhat616 wants to merge 1 commit into
feat/hardening-47-adaptive-windowfrom
fix/hardening-48-hung-connect-evidence

Conversation

@greenhat616

Copy link
Copy Markdown
Owner

PR-6b of the concurrency window redesign (T32; design §8.3, §12, §14.12a, §14.17; decision D32). Stacked on #216, which is its base.

Why

Bench s5 Hang (#216): the server admits 4 connections and lets further connects hang until the connect timeout. The healthy peers finish before the hung connects time out, so at classification no attempt is proven: the refusals are uncorroborated, the silent-limit rule never lowers the limit, and the growth doubles into a second round of hung connects (85 s vs 53 s for the Close variant).

What

C42 fix(task): corroborate a refused connect by the peers it overlapped

  • AdmissionEvidence keeps, per attempt still connecting, the most other attempts in flight seen at a moment when some attempt was proven. At most one value per runner ID; no event log, no clock.
  • Sampling points:
    • spawns;
    • the start of each strategy tick;
    • failures;
    • the frame that first proves an attempt. This includes a first frame that completes its chunk; the attempt is then counted as proven.
  • A refusal with a record is corroborated, at the larger of the recorded level and its classification level, so the reconnects of its ranges keep the streak.
  • The record is consumed at Started or at classification. It is forgotten when the attempt is cancelled while connecting, when the attempt is beaten in its hedged pair, or when its runner ID is reserved again.
  • Unchanged:
    • the lowering conditions: three corroborated refusals, progress a tick later, 1 ≤ connected < limit;
    • STREAK_GAP;
    • the D27 range-budget exemption, which still reads only the moment of classification. An exemption cannot be undone, and widening it would let a range whose own connects always hang never be charged.
  • Growth (B) is untouched.
  • Known misjudgment, documented in §8.3 and §12: an outage while connects hang beside proven peers may lower the limit; recovery steps raise it again.

Bench s5 (10 runs each, median / p90)

Variant Before (C41) After Turned away
Close 53.04 / 53.06 s 53.02 / 53.05 s 13, unchanged
Hang 84.99 / 85.13 s 60.01 / 60.07 s 8 → 4

Only s5 was re-run. The other scenarios have no refused connects (§14.17, stated as inference).

Tests

  • Unit tests for the evidence:
    • overlap corroboration and its level;
    • the record's lifetime across release, classification, Started and re-reservation;
    • the maximum with the current level;
    • step rejection;
    • no exemption.
  • Manager tests: a proof transition is seen beside the connects; a cancelled connect forgets its record.
  • Hedge test: a beaten connecting hedge forgets its record.
  • Loop tests in download_loop/tests/admission.rs:
    • the s5 Hang shape;
    • peers proven and finished between two ticks;
    • peers done in a single frame.
  • Mutations, each failing at least one new test:
    • without the overlap corroboration;
    • level taken at classification only;
    • without the proof-transition sample;
    • the post-frame proof check;
    • without the +1 for a finished attempt;
    • without forget on cancel;
    • without forget on the hedge loser.

Verification

  • fmt and clippy -D warnings pass.
  • cargo test --workspace --all-features: 1061 passed, 0 failed, 1 ignored.
  • cargo bench --no-run passes.
  • Reviewed by codex over three rounds (single backend); final verdict "ready".

A connect the server never answers fails only at the connect timeout.
When the runners that delivered beside it had finished by then, no
attempt was proven at its classification: the refusal was not
corroborated, the limit was not lowered, and the growth doubled into
the silent limit again (bench s5 Hang, design §14.17).

The evidence now keeps, for each attempt still connecting, the most
other attempts in flight at the moments that saw a proven attempt
beside it: spawns, strategy ticks, failures, and the frame that first
proves an attempt (even when that frame completes its chunk). A
refusal with such a record is corroborated, at the larger of that
level and the one of its classification, so the reconnects of its
ranges at a lower level keep the streak. The lowering still needs
progress a tick after the third refusal and some runners connected.
The range budget's exemption (D27) still reads only the moment of the
classification.

A record is consumed at the attempt's classification or Started, and
forgotten when the attempt ends without one (cancelled while
connecting, beaten in its hedged pair) or its runner ID is reserved
again.

s5 Hang now completes in 60.0 s instead of 85.0 s, with four
connections turned away instead of eight; s5 Close is unchanged.

Design notes in §8.3 and §14.12a (D32), numbers in §14.17.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant