Repository navigation
fix(client-pull): keep ingest disk I/O off the tokio runtime - #2121
Merged
Merged
Conversation
ClientRangedStore::ingest_stream ran write_all_at and the 4 MiB checkpoint fsyncs inline on the runtime workers. The paid pull pays from inside that decode loop, so a slow fsync stalled voucher sends on every lane at once, and nodes dropped every stream with "proof read timed out after 10s". ingest_stream now collects each ~4 MiB of verified leaves and parents into a batch and flushes it (write, fsync, union into present) on spawn_blocking, with one flush in flight while the next batch decodes. A stashed peer fault outranks a local flush error, and a flush logs its own failure so a dropped leg does not lose it. Interleaved lanes exposed a scheduler window: a steal cancelled a victim whose range was already fully present, dropping it before its finish. Work::pick now only trims the victim; the stealer cancels it through Work::cancel_victim once its backstop finds missing bytes, and only while the victim still runs the unit the steal trimmed (a per- worker unit counter, so a second steal cannot hide the cancel). Tests: a 1-worker regression test that fails while a flush blocks the worker, fault-path and steal-billing assertions, and three scheduler tests re-anchored off assumptions that only held while ingest never yielded. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unresolved ranged-store finalization and error-propagation issues, plus synchronous record persistence that can still block the runtime.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (3)
What changed in this PR
This PR moves client ingest writes/fsyncs off Tokio workers and hardens scheduler steal cancellation, with related durability documentation and tests.
Changes:
- Batches verified data and outboard checkpoint flushes via
spawn_blocking. - Refines victim cancellation and payment behavior during scheduler steals.
- Updates durability documentation and regression coverage.
| File | Summary |
|---|---|
crates/client-pull/src/scheduler.rs |
Adds safer, unit-aware steal cancellation. |
crates/client-pull/src/ranged_store.rs |
Adds batched asynchronous ingest flushing; unresolved findings cover flush finalization races, I/O error propagation, and crash-bound documentation. |
crates/client-pull/src/driver.rs |
Retains synchronous present-record persistence, which can still block Tokio workers (moderate, 3 votes). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…e fetch The interval owner wrote the `.ranges` record (tempfile + fsync) inline in its select! arm, which both blocked a runtime worker and stopped polling the fetch future, i.e. every lane's pay loop, for the duration of the fsync. IngestStore::flush_present_record now returns a future. The client store snapshots `present` at the call and writes it on spawn_blocking; finalize's pre-sweep record write moves there too. drive_with_interval_flush runs each tick's write beside the fetch, keeps at most one in flight, and lands it before returning so an older snapshot cannot rename over the caller's final one. Also documents that a stream fault or decode failure outranks a flush failure on ingest_stream's error path. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Coverage reportTotal: 83.83% (was 83.82%, ▲ +0.01%) — 88065/105049 lines
History
|
alpergundogdu
added a commit
that referenced
this pull request
Sep 22, 2026
Resolve the #2121 × #1848 re-export overlap in client-pull/lib.rs: keep the #1848 `scheduler::ConsumptionPacing`, `sink::{BlobCache, ByteSink, NoCache, SinkFuture}`, and `streamer::{StreamCandidate, Streamer, VerifiedReader}` re-exports, and add #2121's new `source::SourceFuture`. scheduler.rs auto-merged. 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 #2117
Problem
ClientRangedStore::ingest_streamranwrite_all_atand the 4 MiB checkpointsync_alls inline on the tokio workers. The client pays from inside that decode loop (next_chunk→pay_one), so a slow fsync on a multi-GB sparse.partialstalled voucher sends on every lane at once. Nodes then dropped every stream withproof read timed out after 10s.Fix
ranged_store.rs). Verified leaves and parents collect into ~INGEST_CHECKPOINT_BYTESbatches. Each batch flushes onspawn_blocking: write, fsync data then outboard, then union intopresent(fsync-before-union kept). One flush runs in flight while the next batch decodes, bounding memory at ~2 intervals per stream.Donepaths. A flush logs its own failure, so a detached flush (dropped future) does not lose it. Checkpoint errors name the file and offset.scheduler.rs). Once lanes interleave, a steal could cancel a victim whose range was already fully present, dropping it just beforefinish.Work::picknow only trims the victim. The stealer cancels viaWork::cancel_victimafter its present-bytes backstop finds missing bytes, and only while the victim still runs the unit the steal trimmed. A per-worker unit counter means a second steal from the same victim cannot hide the first stealer's cancel.Out of scope:
VOUCHER_SEND_DEADLINEvs the node'sVOUCHER_READ_TIMEOUT(fix C in the issue).Tests
ingest_stream_slow_flush_does_not_block_the_runtime: 1-worker runtime, 3 s test-only flush delay, ticker max-gap < 1.5 s. Failed with a 2.0 s stall before the fix.ingest_stream_mid_gap_fault_checkpoints_received_prefix: now holds the flush in flight past the fault. Fails if the fault-path reclaim is removed (mutation-checked).forced_steal_no_double_pay_on_multi_thread_runtime: asserts the victim billed its leg. Fails 3/3 with the cancel moved back intopick.steal_cancels_the_victim_only_through_cancel_victim: single steal, double steal, moved-on victim, idle victim.distinct_providers_each_pay_their_own_laneuses disjoint coverage.large_multi_block_gap_seeds_about_one_span_per_holderchecks each holder's first (seeded) open instead of the total open count.forced_steal_does_not_double_fetch_the_stolen_tailwidens the slow start from 200 ms to 1 s.Each was stress-verified against main under parallel load.
Local:
cargo clippy --workspace --all-targets -D warnings, rustdoc-D warnings, fmt, andnextest -p decdn-client-pull -p decdn-cli -p decdn-nodeall pass (2323 tests).Not yet confirmed on testnet. The regression test proves the runtime-starvation mechanism, not the field cause. Re-run the gpt-oss bundle pull and check fra1/lon1/bcl for
proof read timed out.🤖 Generated with Claude Code