Skip to content

Throttle repeated *arr history-error logs (fixes #21)#29

Open
bugrax wants to merge 5 commits into
wouterdebie:mainfrom
bugrax:throttle-arr-error-logs
Open

Throttle repeated *arr history-error logs (fixes #21)#29
bugrax wants to merge 5 commits into
wouterdebie:mainfrom
bugrax:throttle-arr-error-logs

Conversation

@bugrax

@bugrax bugrax commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #21.

When a Sonarr/Radarr instance is misconfigured or unreachable, is_imported fails its history lookup for every transfer on every poll, and each failure logged:

ERROR Error retrieving history from Radarr: error decoding response body

With a 10s poll and any number of transfers that is a continuous stream of identical lines. The reporter saw it grow to ~23 GB and fill a 50 GB disk over a couple of months.

This throttles that specific error to at most once per 5 minutes per *arr (tracked in StateManager). The problem is still visible in the logs, but it can no longer grow without bound. Functional behaviour is unchanged — only the logging is rate-limited.

(A docker logging: max-size is a good defence-in-depth too, but this stops the root cause of the growth.)

When a Sonarr/Radarr is misconfigured or unreachable, the history check
fails for every transfer on every poll, and each failure logged an
error. Over weeks this grew the log to many GB and filled users' disks.
Throttle the error to at most once per 5 minutes per *arr, so the
problem stays visible without runaway log growth.
Copilot AI review requested due to automatic review settings June 9, 2026 20:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR adds throttled logging for connection/history retrieval errors from Sonarr/Radarr to prevent repeated poll failures from spamming logs and filling disk (issue #21).

Changes:

  • Track last logged connection error per *arr in StateManager.
  • Add a configurable throttling interval (ARR_ERROR_LOG_INTERVAL) and a helper method to decide whether to log.
  • Update transfer polling to suppress repeated error logs within the throttling window.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/state.rs Adds per-*arr error log throttling state and should_log_arr_error helper.
src/download_system/transfer.rs Uses throttling helper to suppress repeated “retrieving history” errors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/download_system/transfer.rs Outdated
Comment thread src/download_system/transfer.rs Outdated
Comment thread src/state.rs Outdated
@bugrax bugrax marked this pull request as draft June 9, 2026 21:17
bugrax added 3 commits June 10, 2026 00:25
Key the *arr error throttle on the app's existing name field instead of
app.to_string(), so the suppressed (common) path does no allocation. The
full Display form is still used in the log message itself.
Instant::duration_since can panic if the stored instant is somehow later
than now; saturating_duration_since returns zero instead, making the
throttle robust regardless.
The log message hardcoded '5m' while the interval is defined by
ARR_ERROR_LOG_INTERVAL; format the constant into the message so the two
can't drift if the interval is changed.
@bugrax bugrax marked this pull request as ready for review June 9, 2026 21:30
@wouterdebie

Copy link
Copy Markdown
Owner

@bugrax after merging the other 2 PRs this one has a conflict.. mind having a look?

@bugrax

bugrax commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Done — just merged main in and resolved it. The conflict was in src/state.rs: #27 added the file-name caches there and this PR adds the error-log throttle field/method, so I combined both. It's showing mergeable/clean now. Thanks a lot for merging the other two! 🙏

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.

Logs get bloated if sonarr or Radarr are not properly configured, and eventually fill docker host disk

3 participants