metadata: Cached provider codepath may close file before attempting to truncate it #264
Labels
status/ready
Merged and either fixed or implemented, and released or likely to be released soon.
type/bug
Something isn't working
Version
0.11.0
Description
Hello again,
As mentioned in #247 I've updated to v0.11 and had been using the latest changes to the metadata service with the provided cache provider. It was working well until today when the service was restarted, at which point it attempted to update the mds blob.
It kept failing with
truncate <file name>: file already closed
I noticed here that the decoder when passed the file is closing the file when it is finished. However just a few lines below, if the data is out of date and a file needs updating, then
doTruncateCopyAndSeekStart
is called which attempts to truncate the file that the decoder has already closed.I tried passing the
WithForceUpdate
true option as a workaround but that fails with "invalid argument", I suspect this is because the file was Opened with READ only, and truncate is a write-level permission.I think the suggested fix would be to not defer close the passed readcloser in the decoder (perhaps just pass it as a reader), and also open the file with
OpenFile
passing RW flags rather than just R flags. I can submit a PR if that helps.Reproduction
Open an outdated MDS blob with the cached provider, default settings should reproduce it. For reference here is my abridged constructor, I pass a NewFunc because I need to be able to configure
PermitZeroAAGUID
to the underlying memory providerExpectations
No response
Documentation
No response
The text was updated successfully, but these errors were encountered: