Repository navigation
fix(client,cli): keep the bundle task polled while records and fsyncs run - #2274
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Write reordering, dropped watermark advances, and blocking-pool exhaustion remain unresolved.
Review effort: Balanced
Findings: 2
Open (4)
What changed in this PR
Reduces bundle-pull stalls by moving durable writes off the shared pull task and polling record flushes alongside active lanes.
Changes:
- Offloads peer records and buyer watermarks to blocking workers.
- Deduplicates lane settlements and keeps scheduler flushes in flight.
- Adds stall diagnostics and regression tests.
| File | Description |
|---|---|
| crates/client/src/source.rs | Shares the record-flush test double. |
| crates/client/src/scheduler.rs | Polls record writes beside lane workers. |
| crates/client/src/lib.rs | Logs first-frame waits. |
| crates/client/src/endpoint.rs | Corrects connection-sharing documentation only. |
| crates/client/src/driver.rs | Reuses the shared test double. |
| crates/client/src/discovery.rs | Offloads bootstrap peer-store writes. |
| crates/cli/src/commands/fetch.rs | Offloads and deduplicates watermark persistence. |
| crates/cli/src/commands/cli_sources.rs | Queues peer events and supports asynchronous settlement. |
| crates/cli/src/commands/bundle_pull.rs | Adds a poll watchdog and asynchronous settlement. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit a825a73 in the Show a line coverage summary of the most impacted files.
Updated |
This was referenced Oct 1, 2026
cli, client: log typed RPC errors through sanitize_error_sources so the failure class survives
#2277
Closed
… run A bundle pull runs every entry and lane as one future on the main thread, so any synchronous fsync on that future stops every lane of the run at once. The nodes then see all streams go quiet together and time the legs out (#2211). - discovery: resolve_bootstrap (one peer-record fsync per registry node, then prune_and_cap) runs on spawn_blocking. - cli_sources: record_open / record_failure go to one ordered blocking-pool writer per fetch, so an open's cleared failure never lands after a later fault's stamp. - fetch/bundle_pull: the buyer-progress redb commit runs on spawn_blocking (awaited on the normal path, detached from the drop guard); the store is shared through an Arc. Lane handles that share one ledger now produce one write per entry. - scheduler: the 5 s .ranges record write runs beside the workers instead of being awaited inside the select arm; a write in flight lands before the final flush. - diagnostics: a fresh leg logs its open-to-first-frame wait as phase="first_frame", and bundle pull warns "the bundle task was not polled for ..." when a 1 s tick fires more than 2 s late. - endpoint: the connection receive-window comment reflects that lanes to one node share its connection. Refs #2211 Refs #2230 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NHKbG6Jm75vFMLTNqK8ppz
…t baseline Review follow-up on the off-runtime writes: - One command-wide OrderedWrites queue (fetch: per command, bundle pull: on PullCtx, both through DriveFetchDeps) runs every peer record and voucher-watermark commit on the blocking pool, one at a time, in queue order. A worker runs only while writes are queued and exits when the queue empties, so an idle fetch parks no blocking-pool thread. - Watermark writes are queued in the order the ledgers are read, for both the awaited settle and the drop guard's. Separate spawn_blocking jobs could commit a rebase over a newer advance, or a stale advance over a rebase, across concurrent entries. - Peer records from different bundle entries share that order, so one entry's first open never clears another entry's later fault stamp. - A ledger's one watermark takes the lowest prior_amount across its handles, so an advance past a sibling's rebased baseline persists. Refs #2211 Refs #2230 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NHKbG6Jm75vFMLTNqK8ppz
…re exit Review fixes for the off-runtime writes: - OrderedWrites runs each write under catch_unwind, logs the panic and keeps draining, so a panicking write strands nothing behind it and an awaited settle cannot hang. A worker the runtime drops without running (shutdown) drains the queue on the dropping thread. - fetch and bundle pull own the queue at command level and wait for it, bounded by WRITE_DRAIN, before endpoint.close() on every exit, a Ctrl-C's included, so a drop guard's watermark write is durable before the command returns. - The ledger read and the watermark queueing are one pub(crate) call (queue_face_watermarks); the read-only and Vec-taking halves are private. - The watermark-write warning names the lanes, pools and providers and the likely cause. - scheduler: a superseded periodic record write's failure is logged and the final write decides; distinct post-loop warn; debug line on a skipped tick. - discovery: the bootstrap JoinError keeps its source with context. - The poll-watch WARN says the lateness is a lower bound and what to do. - Docs and comments match the code (ordering precondition on one task, Ctrl-C durability, scope of the ordered writes, first_frame timing). Tests: panic does not strand a later awaited write; a dropped worker drains; racing submitters lose nothing; a detached settle lands by runtime shutdown; the final record snapshot lands last on both the success and give-up exits; the slow-record test is bounded to 2 min; every new await is bounded. Refs #2211 Refs #2230 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NHKbG6Jm75vFMLTNqK8ppz
thiras
force-pushed
the
fix/2211-bundle-task-polled
branch
from
October 2, 2026 02:46
f3b34d3 to
a825a73
Compare
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.


What
This PR keeps the
decdn bundle pulltask polled while durable writes run, and adds diagnostics for the stalls in #2211 and #2230. It is PR 1 of 3.A bundle pull runs every entry and lane as one future on the main thread (
block_on, with notokio::spawnby design). Synchronous fsyncs on that future, and one inline await in the scheduler, left every lane of the run unpolled at the same moment. The nodes then saw every stream go quiet together. That matches the 21 s client-side silence, followed by 12 lane faults on 3 providers, reported in #2211.Summary
Ordered state writes off the runtime thread. A new command-wide
OrderedWrites(crates/cli/src/commands/ordered_writes.rs) runs these writes on the blocking pool, one at a time, in queue order:record_open);record_failure);Ordering matters because an open that lands after a later fault clears that fault's stamp, and a watermark rebase replaces the lane row outright. How the queue behaves:
decdn fetchanddecdn bundle pullown the queue at command level. Beforeendpoint.close(), on every exit including a Ctrl-C, they wait for it, bounded byWRITE_DRAIN(30 s).Watermark capture order.
queue_face_watermarksreads the lane ledgers and queues the writes in one synchronous call. Commit order is therefore read order across entries, as long as every entry is polled on one task (buffer_unordereddoes this).prior_amountacross the handles, so an advance past a sibling's rebased baseline still persists.Registry bootstrap off the runtime thread.
bootstrap_nodesrunsresolve_bootstraponspawn_blocking. On each discovery, that function writes and fsyncs one peer record per registry node, then runsprune_and_cap.Scheduler record flush beside the workers.
.rangeswrite is now an in-flight future with its ownselect!arm, following the pattern ofdrive_with_interval_flush.Diagnostics.
phase="first_frame".bundle pullruns a 1 s poll watch. It logs a WARN, "the bundle task was not polled for at least …", that points at a blocking call (or a system suspend) and suggests-vv. The lateness it reports is a lower bound.Comments. The comment on
CLIENT_RECEIVE_WINDOWnow says that lanes to one node share that node's connection.Root cause (file refs)
crates/client/src/discovery.rs,resolve_bootstrap: N peer-record fsyncs and a prune on each discovery, reached throughCliSources::discover→resolve_target_node→bootstrap_nodes.crates/cli/src/commands/cli_sources.rs,on_source_fault/record_open: one fsync per fault or open, made from a sync hook on the pull future.crates/cli/src/commands/fetch.rs, watermark persistence: one redb fsync per lane handle at each entry end. The handles were not de-duplicated.crates/client/src/scheduler.rs, the record tick arm:store.flush_present_record()was awaited inline, so no worker was polled while the write ran.Refs #2211
Refs #2230
Reviewer notes
ordered_writes.rsfirst, thenscheduler.rs(therecordslot), thenqueue_face_watermarksinfetch.rs.pubitem ofdecdn-clientordecdn-protocolchanged.FlushCountingStoremoved into the shared#[cfg(test)]doubles insource.rs. It now numbers each flush, and it can land its writes out of order, so a test can check which snapshot landed last.upsert_identityno-op skip.identity_seen_at_secsmeans "last confirmed against the registry" and drivesidentity_fresh/identity_prunable, so skipping the upsert would make it lie.spawn_harvest'srecord_samplewrites throughOrderedWritesas well. That code predates this PR, and it still runs on atokio::spawntask.Verification
cargo fmt -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run -p decdn-client -p decdn-cli: 1372 passedRUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-itemspre-commit run --files <changed files>scheduler:a_slow_record_write_does_not_pause_the_lanes: bounded to 2 min; fails fast with the inline flush.the_final_record_lands_last_when_the_fetch_completesthe_final_record_lands_last_when_the_fetch_gives_upordered_writes:writes_run_in_queue_order_and_the_worker_exits_when_idlea_panicking_write_does_not_strand_the_writes_behind_ita_worker_the_runtime_drops_still_drains_the_queueracing_submitters_never_strand_a_writea_write_after_an_idle_spell_still_runsfetch:duplicate_lane_handles_commit_once_from_the_lowest_baselinea_rebase_read_first_never_lands_over_a_newer_advanceanda_stale_advance_read_first_never_lands_over_a_rebase: these pin the end state; they cannot deterministically catch a per-call spawn.a_detached_settle_lands_by_runtime_shutdown: no mutation run for this one.cli_sources:an_open_and_a_later_fault_from_two_entries_land_in_orderdecdn bundle pull(Mistral or SDXL) withRUST_LOG=info,decdn_cli=debug,decdn_client=debug. Look for "the bundle task was not polled" andphase="first_frame". This runs after PRs 1–3 merge, before the issues close.contracts/changed: n/aCHANGELOG.mdentry added. n/a: this PR adds diagnostics and an internal fix only.🤖 Generated with Claude Code
https://claude.ai/code/session_01NHKbG6Jm75vFMLTNqK8ppz