Skip to content

feat(clients): better IPFS timeout handling - #3745

Merged
Alenar merged 8 commits into
mainfrom
djo/3680/client-ipfs-better-timeout-handling
Dec 4, 2026
Merged

Alenar merged 8 commits into
mainfrom
djo/3680/client-ipfs-better-timeout-handling

Conversation

@Alenar

@Alenar Alenar commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Content

This PR improves the handling of a slow Kubo node during an IPFS download of a Cardano database with the client. A single files/stat timeout was handled like an unreachable node: it tripped the IPFS circuit breaker and disabled IPFS for all the remaining files, and that was only reported in the logs.

This PR includes:

  • Retries of the files/stat existence check with increasing timeouts (2s, 5s, 10s then 15s, instead of a single 5s attempt):
    • A retry is made only when the previous attempt timed out. A connection error or a Kubo error still fails at once.
    • Each attempt warms up the Kubo node for the next one (fetched blocks and connected providers are kept), which helps with a slow DHT provider lookup on a cold node.
    • Once every attempt has timed out, the node is reported as unreachable and the circuit breaker trips as before.
  • A new DownloadSourceDisabled { download_id, source } feedback event, sent once by the circuit breaker when it trips (source is IPFS).
  • A warning in the client CLI when that event is received. It is displayed through the progress bars, or as a JSON caution when the JSON output is enabled:

    Warning: IPFS download source disabled, the remaining files are downloaded from the other locations

  • BREAKING: the MithrilEvent and MithrilEventCardanoDatabase feedback events are now #[non_exhaustive]. Adding the new event was already a breaking change for exhaustive matches, so this change makes future events non-breaking.
  • The IPFS download section of the client CLI documentation describes the retries and the warning.

Pre-submit checklist

  • Branch
    • Tests are provided (if possible)
    • Crates versions are updated (if relevant)
    • CHANGELOG file is updated (if relevant)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
  • PR
    • All check jobs of the CI have succeeded
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested
  • Documentation
    • Update documentation website (if relevant)
    • No new TODOs introduced

Comments

Instead of the counter of consecutive timeouts suggested in the issue, each files/stat call is retried with increasing timeouts, so the circuit breaker stays a simple on/off switch with no threshold to tune. Once tripped, it is not reset for the rest of the download.

The CLI warning is not covered by a test, as the indicatif output can't be captured.

With the 15s attempt, a file that ends up falling back to cloud storage now waits at most 32s (2 + 5 + 10 + 15). The docs and the CHANGELOG give no timeout values, so they don't need updating.

Issue(s)

Closes #3680

@Alenar Alenar self-assigned this Dec 2, 2026
@Alenar Alenar added the optimization 🛠️ Optimization and/or small enhancements label Dec 2, 2026
@Alenar
Alenar requested a review from damrobi as a code owner December 2, 2026 14:45
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Test Results

     5 files  ±0     211 suites  ±0   57m 13s ⏱️ + 1m 46s
 4 851 tests +2   4 851 ✅ +2  0 💤 ±0  0 ❌ ±0 
16 029 runs  +8  16 029 ✅ +8  0 💤 ±0  0 ❌ ±0 

Results for commit 9027fe8. ± Comparison against base commit 9a5abbb.

This pull request removes 1 and adds 3 tests. Note that renamed tests count towards both.
mithril-client ‑ file_downloader::ipfs::tests::files_stat_timeout_raise_unreachable_file_downloader_error
mithril-client ‑ cardano_database_client::download_unpack::download_task::circuit_breaker::tests::trigger_sends_a_download_source_disabled_event_only_once
mithril-client ‑ file_downloader::ipfs::tests::files_stat_is_retried_with_the_next_timeout_when_it_times_out
mithril-client ‑ file_downloader::ipfs::tests::files_stat_timeout_of_every_attempt_raise_unreachable_file_downloader_error

♻️ This comment has been updated with latest results.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The review record identifies no active issues, and the documented IPFS retry, disabled-source feedback, and forward-compatible enum changes support the requested improvements.

No open issues 🎉

What changed in this PR

Improves client IPFS downloads by retrying slow Kubo files/stat requests, notifying users when IPFS is disabled, and making feedback enums forward-compatible.

Changes:

  • Added progressive existence-check timeouts and circuit-breaker feedback.
  • Added CLI warnings and JSON cautions for disabled IPFS sources.
  • Updated documentation and changelog.
  • A moderate issue remains: connection timeouts are retried instead of immediately tripping the circuit breaker; a test name also has a grammatical nit.
File Description
mithril-client/​src/​file_downloader/​ipfs.rs Implements progressive timeout retries for IPFS existence checks and adds tests.
mithril-client/​src/​feedback.rs Adds the source-disabled feedback event and non-exhaustive feedback enums.
mithril-client/​src/​cardano_database_client/​download_unpack/​internal_downloader.rs Integrates the IPFS circuit breaker with the download flow.
mithril-client/​src/​cardano_database_client/​download_unpack/​download_task/​task.rs Triggers circuit-breaker handling asynchronously during downloads.
mithril-client/​src/​cardano_database_client/​download_unpack/​download_task/​circuit_breaker.rs Emits the source-disabled event once when the breaker trips.
mithril-client-cli/​src/​utils/​multi_download_progress_reporter.rs Displays source-disabled warnings through progress output.
mithril-client-cli/​src/​utils/​mod.rs Provides shared warning formatting utilities.
mithril-client-cli/​src/​utils/​feedback_receiver.rs Handles source-disabled feedback for CLI output.
docs/​website/​root/​manual/​develop/​nodes/​mithril-client.md Documents IPFS retries and fallback behavior.
CHANGELOG.md Records the IPFS handling and breaking API changes.

Review effort: Lite

@Alenar
Alenar force-pushed the djo/3680/client-ipfs-better-timeout-handling branch from e9b863b to 96457e7 Compare December 2, 2026 17:44

@turmelclem turmelclem left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@jpraynaud jpraynaud left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@damrobi damrobi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

A single slow `files/stat` answer of the Kubo node tripped the IPFS
circuit breaker for the remaining files of a download.
The call is now retried on timeout only (2s, 5s, 10s, then 15s), each
attempt warming up the node for the next one, and is reported as
unreachable once all attempts time out.
… IPFS circuit breaker trips

The circuit breaker is built with the feedback sender, the download id
and the type of its download source, and reports its first trip, so
client users are told which source is disabled and that the remaining
files are downloaded from their other locations instead of finding it
only in the logs.
The `DownloadSourceDisabled` feedback event is displayed as a warning
through the progress bars (or as a json `caution` with the json output),
so users know that the remaining files are downloaded from the other
locations.
`MithrilEvent` and `MithrilEventCardanoDatabase` are now
`#[non_exhaustive]`, so that adding a feedback event is no longer a
breaking change for the users of the library, who must handle unknown
events with a wildcard arm.

This solve a gap has we should have added this attribute at the same
time as those enums.
* mithril-client-cli from `0.14.3` to `0.14.4`
* mithril-client from `0.15.5` to `0.15.6`
@Alenar
Alenar force-pushed the djo/3680/client-ipfs-better-timeout-handling branch from 96457e7 to 9027fe8 Compare December 3, 2026 16:45
@Alenar
Alenar deployed to testing-preview December 3, 2026 17:15 — with GitHub Actions Active
@Alenar
Alenar deployed to testing-2-preview December 3, 2026 17:15 — with GitHub Actions Active
@Alenar
Alenar merged commit b254d7e into main Dec 4, 2026
53 of 54 checks passed
@Alenar
Alenar deleted the djo/3680/client-ipfs-better-timeout-handling branch December 4, 2026 08:58

This branch was successfully deployed

2 active deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimization 🛠️ Optimization and/or small enhancements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trip the IPFS circuit breaker only when the Kubo node is unreachable in the client

5 participants