Skip to content

node: E2E test that concurrent same-hash window pull-through requests open ONE upstream pull (no double spend) #895

Closed

Description

@thiras

Follow-up from the #893 review (implements #856). Test-coverage gap.

Gap

The cache-level coalescing primitive is unit-tested (crates/cache/src/engine.rs tee_sink_coalesces_concurrent_fills), but the handler-side consequence has no end-to-end test: at crates/node/src/handlers/client.rs:898 a TeeOpen::InFlight must NOT open a second upstream pull — it waits via await_coalesced_fill, then serves-or-misses. This is the no-double-spend guarantee (#305) at the layer that actually spends real USDC.

Suggested test

Two concurrent leaf requests for the same uncached hash against node B (window provider attached):

  • assert a single upstream pull (via progress_log / upstream bytes ≈ one blob, not two),
  • assert both leaves are served (or the second cleanly serves from the coalesced fill).

Concurrency makes this harder to write deterministically (hence low priority), but it pins a correctness guarantee the unit test cannot.

Filed from the #893 multi-agent review.

Activity

  1. added
    rust
    kind:test
    prio:low
    on Jun 13, 2026
  2. added a commit that references this issue on Jun 13, 2026
  3. github-actions commented on Jun 13, 2026

    @github-actions

    🎯 Triage report

    This is a targeted test-coverage gap: the cache-level coalescing primitive has a unit test (tee_sink_coalesces_concurrent_fills in crates/cache/src/engine.rs), but there is no handler-level E2E test verifying that TeeOpen::InFlight at crates/node/src/handlers/client.rs:898 suppresses a second upstream pull. Since this path is where real USDC vouchers are emitted, the correctness guarantee (#305, now closed) is unverified at the layer that actually has economic consequences. The filer explicitly marks this low-priority due to concurrency determinism difficulty, and the description is self-contained with a clear test shape.

    📊 Assessment

    Dimension Value Reasoning
    Type Task Adding test coverage; no production logic change.
    Labels technical, rust, testing, low (all already applied) Accurate; no additions needed.
    Coding agent Needs more info Scenario is clearly described, but the concurrency harness is non-trivial — a coding agent would need the existing E2E test infrastructure pattern (window provider setup, progress_log or upstream-bytes assertion hook) spelled out to avoid a flaky test.

    🔗 Similar issues

    💡 Notes and suggestions

    Where to look when implementing:

    • Existing unit test to mirror: crates/cache/src/engine.rs → tee_sink_coalesces_concurrent_fills — use this for the coalescing assertion pattern.
    • Handler under test: crates/node/src/handlers/client.rs:898 — the TeeOpen::InFlight arm calls await_coalesced_fill; the test should verify this arm is hit for the second request, not a new try_pull_through.
    • Upstream-pull counting: the issue suggests using progress_log or comparing upstream bytes ≈ one blob. An alternative is a counter on the origin mock/stub — fire two concurrent requests, assert the origin was fetched exactly once.

    Concurrency determinism suggestions:

    1. Use a tokio::sync::Barrier to synchronize both request tasks so they arrive at the handler simultaneously (before the first fill completes).
    2. Introduce a deliberate delay in the origin stub to widen the concurrency window and make the race reliably exercisable.
    3. Assert both: upstream_fetch_count == 1 AND responses_served == 2 (or second cleanly serves from local blobs after coalesced fill).

    Sub-task checklist:

    • Set up an in-process node B with a window provider (USDC channel stub) and a slow origin adapter.
    • Spawn two concurrent cdn/client/v1 requests for the same uncached hash.
    • Assert origin fetch count = 1 (single upstream pull, not two).
    • Assert both requests receive the blob successfully (or second cleanly serves from completed fill).
    • Verify no double voucher emission on the upstream side.

    Risk note: If this test is flaky due to scheduling, a tokio::test(flavor = "multi_thread") with explicit barriers is preferable to current_thread. The existing pattern in tee_sink_coalesces_concurrent_fills may already demonstrate the right approach.

    Generated by Agentic Triage for issue #895 · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
  4. self-assigned this
    on Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:testprio:lowrust

Type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions