Skip to content

a candidate can now cost 2x pull_timeout, but outer_pull_deadline still budgets 1x #1147

Closed

Description

@thiras

Spun out of the multi-agent review on #1145.

Problem

After #1143, open_from_candidate spends two sequential full pull_timeout budgets on a single candidate:

.open_or_reuse_channel(provider_addr, deps.config.deposit_hint, deps.config.pull_timeout)  // budget #1
...
tokio::time::timeout(deps.config.pull_timeout, open_progressive_upstream(...))              // budget #2

But outer_pull_deadline is unchanged — MAX_PROVIDER_ATTEMPTS × per_candidate + PULL_THROUGH_OUTER_SLACK = 3 × 20s + 10s = 70s at defaults, while a single candidate can now cost 40s. Add discover + probe_and_rank and the loop can reach fewer than two candidates before the handler's outer timeout cancels the whole fetch — defeating MAX_PROVIDER_ATTEMPTS = 3.

Worked example: a candidate whose channel open lands slowly (19s, inside budget) and whose peer then stalls the handshake costs 39s, not 20s.

selection.rs's outer_pull_deadline doc — rewritten in #1145 — asserts the arithmetic still holds. It doesn't, for this case.

Not a regression

Before #1143, open_or_reuse_channel was fully unbounded, so one candidate could eat the entire outer deadline. This is strictly better; it just stops one notch short of the guarantee the doc claims.

Suggested fix

Either:

  • budget the outer deadline at MAX_PROVIDER_ATTEMPTS × 2 × per_candidate + slack; or
  • (better) make the per-candidate budget a deadline rather than two independent durations: pass an Instant down and derive each stage's remaining budget from it, so channel_open + open ≤ per_candidate by construction.

The second removes the whole class of bug rather than re-tuning a constant, and would also let PullDeadlines be derived from one budget instead of two positionally-passed Durations.

Also worth folding in

a_wedged_channel_open_does_not_starve_the_candidate_loop uses only two candidates, so it cannot catch this. A three-candidate variant would.

Related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions