> Which is why you need full fsync- which is coordinated all the way down

I don't understand this reply; file.Sync() does fsync syscall on POSIX
(and with F_FULLFSYNC on macOS).

Yes it's slower, but it's not really documented that it might be
necessary. (It did cause us trouble in reality when the whole OS
crashed for an unrelated reason.)

On Thu, 17 Apr 2025 at 16:17, Robert Engels <reng...@ix.netcom.com> wrote:
>
> Even if the OS writes it to disk there is the possibility of failure due to 
> lazy writes by the drive itself. Which is why you need full fsync- which is 
> coordinated all the way down. It is also many orders of magnitude slower. See 
> this for performance difference details 
> https://github.com/robaho/cpp_leveldb?tab=readme-ov-file#performance
>
> On Apr 16, 2025, at 6:09 PM, Karel Bílek <k...@karelbilek.com> wrote:
>
> I was quite surprised recently that, at least on linux, file.Close() does 
> not guarantee file.Sync(); in some edge-cases, files can be not put properly 
> to filesystem.
>
> If the data integrity is critical, it seems better to call file.Sync() before 
> file.Close().
>
> (Linux has this in close / fsync syscall manpages.)
>
> I am surprised that the docs don't mention this; also, that os.WriteFile does 
> not call file sync, so even when os.WriteFile() returns no error, it doesn't 
> mean the file is actually written on the disk!
>
> I have 2 questions
>
> 1) should this be documented in godoc somewhere?
> 2) should os.WriteFile explicitly call fsync?
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion visit 
> https://groups.google.com/d/msgid/golang-nuts/dd574b31-8146-4710-9937-a56e8ecbe428n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/CAGUkT8bqhzjCqP3i2GTV74F2EYbFcvvmpqZCqh8rYucdG-2Bcw%40mail.gmail.com.

Reply via email to