Skip to content

fix(bootstrap): keep snapshot progress bar live during ranged download#1026

Merged
scarmuega merged 1 commit into
mainfrom
fix/bootstrap-progress-bar
Jun 20, 2026
Merged

fix(bootstrap): keep snapshot progress bar live during ranged download#1026
scarmuega merged 1 commit into
mainfrom
fix/bootstrap-progress-bar

Conversation

@scarmuega

@scarmuega scarmuega commented Jun 20, 2026

Copy link
Copy Markdown
Member

Problem

Follow-up to #1025 (ranged ring-buffer snapshot download). During a bootstrap the progress bar looked frozen even though the download was clearly progressing.

Root cause

In the ranged downloader, progress was advanced once per completed 64 MiB chunk. So the bar sat motionless for seconds at a time while a chunk downloaded, then jumped — the opposite of the old single-stream path, which incremented on every small read and therefore looked smooth.

Fix

  • Increment per read (256 KiB granularity) as bytes arrive within each chunk, instead of once per finished chunk.
  • Roll back a failed attempt's bytes before retrying, so a retried chunk re-downloads its range without the bar over-counting past the total.
  • Enable a steady tick (120 ms) so the bar keeps redrawing even while the downloader is legitimately paused on window backpressure (waiting for the extractor to free a slot).

Verification

  • cargo build + cargo clippy clean.
  • Live-endpoint e2e test (ranged_matches_direct_fetch, --ignored) passes, including its progress.position() == total assertion — confirming per-read increments sum exactly to the total with no double-count.

🤖 Generated with Claude Code

Summary by CodeRabbit

Bug Fixes

  • Download progress bars now continuously update in real-time as data streams during ranged requests, replacing batch updates after completion.
  • Progress displays remain responsive during snapshot downloads, preventing the UI from appearing frozen during system backpressure handling.

The bar only advanced once per completed 64 MiB chunk, so it sat still for
seconds at a time and looked frozen even though the download was progressing.

Increment progress as bytes arrive within each chunk (rolling a failed attempt's
bytes back before retry so the count never overshoots the total), and enable a
steady tick so the bar keeps redrawing while the downloader is blocked on window
backpressure.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d3bbe3fa-05fd-4b3b-92a7-868b0ba72165

📥 Commits

Reviewing files that changed from the base of the PR and between 0452ec2 and e6bda99.

📒 Files selected for processing (2)
  • src/bin/dolos/bootstrap/ranged.rs
  • src/bin/dolos/bootstrap/snapshot.rs

📝 Walkthrough

Walkthrough

The ranged download helper try_download_chunk is updated to accept a ProgressBar, increment it per received byte-chunk during streaming, and roll back the progress position by the bytes written on failure before retrying. download_chunk removes its post-success increment and passes the progress handle down. In snapshot.rs, enable_steady_tick(120ms) is added to keep the progress bar redrawing during extractor backpressure.

Changes

Ranged download progress bar improvements

Layer / File(s) Summary
Streaming progress accounting with retry rollback
src/bin/dolos/bootstrap/ranged.rs
try_download_chunk now accepts a ProgressBar, increments it per received chunk, and rolls back (saturating_sub(written)) on error before returning failure. download_chunk's retry loop passes the progress handle down and removes its prior success-only increment. Doc comments updated to describe rollback semantics.
Steady tick for backpressure pauses
src/bin/dolos/bootstrap/snapshot.rs
fetch_snapshot_ranged calls progress.enable_steady_tick(Duration::from_millis(120)) so the progress bar continues redrawing while the download thread blocks on extractor backpressure.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • txpipe/dolos#1025: Introduced the ranged ring-buffer downloader logic in ranged.rs, including the original download_chunk/try_download_chunk structure that this PR modifies for per-chunk progress accounting.

Poem

🐇 Hoppity-hop through the byte stream I go,
Watching the progress bar put on a show!
Each chunk ticks the bar, no more sudden jump,
On failure I roll back — no misleading lump.
Steady tick keeps the spinner alive,
Even when backpressure says "don't you arrive!"
A rabbit-approved download, smooth as a dive. 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: keeping the snapshot progress bar responsive during ranged downloads by adding steady tick mechanism and per-read increments.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/bootstrap-progress-bar

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@scarmuega scarmuega merged commit 6d01a9d into main Jun 20, 2026
12 checks passed
@scarmuega scarmuega deleted the fix/bootstrap-progress-bar branch June 20, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant