Fix ProgressiveDownloader
reporting wrong doubled values of downloa…
#8579
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.
Fix
ProgressiveDownloader
reporting wrong doubled values of downloaded bytes and percent after 'No space left on device'IOException
and retry.This case added as a unit test in
ProgressiveDownloaderTest
download_afterSinkException_reportsValidProgress()
method.The main source of problem was that in
CacheDataSink
underlying file got removed afterOutputStream.flush()
failed incloseCurrentOutputStream()
method. This information doesn't propagate to CacheWriter logic. And wrong progress/bytesCached reported when user callscache()
method second time.To fix this we need to propagate information about file getting removed and set
initialized
flag to false.There was a corner case where
OutputStream
throws exception either inwrite()
and inflush()
methods. The second error was lost, but the second is an important one because in it a file was removed. To fix this case we need to replace the original exception with the second one instead of usingUtil.closeQuietly()
method.For context, the stacktrace when ENOSPC raised by device:
But for better picture please see Unit Tests.
To reproduce the bag in this branch:
CacheWriter
line 151 comment outinitialized = false
ProgressiveDownloaderTest.download_afterSinkException_reportsValidProgress