Skip to content

client: the size open's primed whole-blob pull is closed when another lane builds in the same first batch #2740

Closed

Description

@thiras

Symptom

crates/e2e/tests/peer_store_probeless.rs fails about 1 run in 5 to 10 on main (b8ef2e9) at the served-bytes check of journey 1's fetch #2:

Error: the holders wrote 397476 bytes for a 198610-byte pull: the first size claim's stream was not the download's first leg

The holders serve the blob twice.

Cause

Fetch #2 is a peer-store fast-path download with no size hint. LaneSources::first_claim opens the whole blob on one holder for its signed size, primes that pull on the lane with PrimedSource::prime_next, and parks the lane. The download's first leg on that lane adopts the pull only when the leg is exactly the whole blob.

The acquire loop plans the work across the first batch of lanes that finish building. The parked lane reached the loop through SourceProvider::connect, as a build future in connecting, beside the fresh builds of the other two holders. The connecting branch drains every build that has already finished into one batch (now_or_never). The parked lane's build resolves at once. When another holder's build also finished by then (a warm connection makes it quick), the batch held two lanes, Work::seed split the blob between them, and the parked lane's first leg was half the blob. PrimedSource::take then closed the primed pull ("a primed pull the next open did not take is closed") after the node had written the whole 198 KB blob into it, and the two legs pulled the blob again.

Failing run, client debug log of fetch #2:

planned the missing ranges across the first lanes total_bytes=197842 lanes=2 pending=0+114688,114688+83154
lane starts provider=0x4BAC… slot=0 coverage=whole blob
lane starts provider=0x849d… slot=1 coverage=whole blob
a primed pull the next open did not take is closed
opening a paid leg peer=2d7d… byte_offset=0 byte_len=114688
opening a paid leg peer=18b8… byte_offset=114688 byte_len=83154

Every passing run logs lanes=1 pending=0+197842 and no leg open. In a 10-run loop, the one failure was the one run with lanes=2, and it was also the slow run (total_ms=984 against 125 to 176 ms).

#2724: unmasked, not introduced

#2724 changed only the discovery trigger. The batch race is in code that #2724 did not touch: the parked lane goes through connect, and the connecting branch batches finished builds. A discovery future in discovering is polled after connecting in the biased select!, so it never changed what the first batch held. Before #2724, a slow fetch also gave the first-pass discovery time to probe the holders mid-transfer, so a slow run failed earlier, at the fetch #2 probed the holders assertion, and never reached the served-bytes check.

Fix

A lane that the provider built before the set starts with no build: SourceProvider::built (default None) hands it over, and the acquire loop starts it in the pass that starts its provider, before it polls any build. The first batch then holds that lane alone, and the plan gives it the whole blob. LaneSources returns its parked lane there.

Activity

  1. added
    kind:bug
    kind:test
    area:client
    on Oct 28, 2026
  2. moved this from Backlog to In progress in deCDNon Oct 28, 2026
  3. moved this from In progress to Done in deCDNon Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clientkind:bugkind:test

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions