Repository navigation
vfscache: fix log message growing without bound on repeated write errors - #9776
Merged
Merged
Conversation
Write() overwrote a successful write's nil error with the stale lastErr returned by kickWaiters() once the downloader had recorded too many errors. download() then wrapped that stale error again and stored it back as the new lastErr, so every subsequent write added another "vfs reader: failed to write to cache file:" prefix - fixes rclone#4998
2 of 3 tasks
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 is the purpose of this change?
Fixes #4998 — when the VFS cache runs out of space, the error message logged on each retry grows without bound, repeating
vfs reader: failed to write to cache file:hundreds of times (243 repeats in the reporter's log).Root cause
downloader.Write()performs the actual cache write and gets its own error fromWriteAtNoOverwrite(nil when the write succeeds). Its deferred kick block then callskickWaiters(), which returns the downloaders' accumulatedlastErronceerrorCountexceedsmaxErrorCount(or on out-of-space). That stale error was assigned toWrite's named return, so:download()wrapped that returned error invfs reader: failed to write to cache file: %w._countErrorsstored the newly wrapped error back aslastErr.Since
lastErris only cleared when a download completes with no error, the loop kept re-wrapping its own message.The
kickWaiters()failure is already logged on the line above, so returning it as thisWrite's error is redundant as well as the source of the growth.Was the change discussed in an issue or in the forum before?
#4998, and the linked forum thread.
Checklist
docs/content/changelog.mdif appropriate. (n/a — bugfix, changelog is generated from commit messages)Testing
Added
TestDownloaders/WriteDoesNotFailOnStaleError, which puts the downloaders into the state that triggers the bug (errorCountpastmaxErrorCount, a stale wrappedlastErr, and an undispatched waiter sokickWaitersreaches the error check) and asserts that a successfulWritestill returns no error. The test output confirms it exercises the real path:go test ./vfs/...passes in full, andgofmt/go vetare clean.