Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

Reset EOF if a partial write was possible #222

Merged
merged 1 commit into from Jan 20, 2017

Conversation

rnewson
Copy link
Member

@rnewson rnewson commented Jan 19, 2017

We can't know if one or more bytes were written by a file:write/2 call
that results in an error and so it is not correct to leave #file.eof
at its original value. In the event of error, use file:position(Fd,
eof) to find the new, true length of the file, and update #file{}
accordingly.

COUCHDB-3274

We can't know if one or more bytes were written by a file:write/2 call
that results in an error and so it is not correct to leave #file.eof
at its original value. In the event of error, use file:position(Fd,
eof) to find the new, true length of the file, and update #file{}
accordingly.

COUCHDB-3274
@davisp
Copy link
Member

davisp commented Jan 19, 2017

+1

Also a note that this was caught by inspection and remembering we've seen weirdness when a hdd runs out of space. A possible cause would be getting enospc errors from writes and then using an incorrect eof after some space had been recovered.

@rnewson
Copy link
Member Author

rnewson commented Jan 20, 2017

I noted that in the JIRA ticket but worth repeating here.

I struggled (and ultimately failed) to add a test here, as it involves either a full mocking out of file or setting up a very small device (e.g, a 1mb ram disk). I did the ram disk approach for manual testing, fwiw.

@asfgit asfgit merged commit 604edd1 into apache:master Jan 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants