Skip to content

vfs/cache: fix exponentially growing error messages in download retries - #9258

Closed
mango766 wants to merge 1 commit into
rclone:masterfrom
mango766:fix/vfs-cache-error-message-growth
Closed

mango766 wants to merge 1 commit into
rclone:masterfrom
mango766:fix/vfs-cache-error-message-growth

Conversation

@mango766

Copy link
Copy Markdown

Summary

Fixes #4998

When the VFS cache runs out of disk space (or encounters repeated download errors), each retry in the downloader wraps the previous error with the same "vfs reader: failed to write to cache file:" prefix. This happens because:

  1. download() wraps any error from WriteTo() with the prefix
  2. On failure, the wrapped error is stored as lastErr via countErrors()
  3. kickWaiters() propagates lastErr back through Write() as the return error
  4. WriteTo() returns this error to download(), which wraps it again

After ~243 retries, the error message contains the prefix repeated 243 times, producing log lines that are tens of kilobytes long and causing massive log file growth.

Fix

In download(), check whether the error already contains the "vfs reader: failed to write to cache file" prefix before wrapping it again. The prefix string is extracted into a named constant (errCacheWritePrefix) to keep the check DRY.

This is a minimal, targeted fix that prevents the exponential error message growth while preserving the full error chain for the first occurrence.

Test plan

  • go build ./vfs/vfscache/downloaders/ compiles cleanly
  • go test ./vfs/vfscache/downloaders/ passes (6.764s)
  • Manual verification: mount with --vfs-cache-mode=full and a small --vfs-cache-max-size, trigger cache-full condition, verify log messages no longer grow exponentially

When the VFS cache runs out of space and download retries occur, error
messages grow exponentially because each retry wraps the previous
error with the same "vfs reader: failed to write to cache file:" prefix.
This happens because kickWaiters() propagates the lastErr (from a
previous download attempt) back through Write(), and download() wraps
it again unconditionally.

After ~243 retries the error message contains the prefix repeated 243
times, causing massive log files (reported in issue rclone#4998).

Fix by checking whether the error already contains the wrapping prefix
before adding it again in download(). Extract the prefix string into a
named constant to keep the check DRY.

Fixes rclone#4998

Co-Authored-By: Claude (claude-opus-4-6) <[email protected]>
@ncw

ncw commented Aug 27, 2026

Copy link
Copy Markdown
Member

I'm closing this in favor of #9776 - sorry we didn't get round to merging this.

@ncw ncw closed this Aug 27, 2026
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.

Mount: When the cache space is insufficient, repeated strings will be generated in the log file.

3 participants