4 ms·
Did I miss it or is there no call to os.File.Sync(), i.e. fsync, anywhere? Since you mention etcd/wal: https://github.com/etcd-io/etcd/blob/v3.3.27/wal/wal.go
by eatonphil 2y ago
Did I miss it or is there no call to os.File.Sync(), i.e. fsync, anywhere?
Since you mention etcd/wal:
https://github.com/etcd-io/etcd/blob/v3.3.27/wal/wal.go#L671 https://github.com/etcd-io/etcd/blob/v3.3.27/wal/wal.go#L671
https://github.com/etcd-io/etcd/blob/v3.3.27/pkg/fileutil/sync.go https://github.com/etcd-io/etcd/blob/v3.3.27/pkg/fileutil/sy...
- stym06 2y agoI used the bufio flush mechanism https://pkg.go.dev/bufio#Writer.Flush https://pkg.go.dev/bufio#Writer.Flush Thanks for your comment, I'll definitely check it out. It was my first attempt at this. How can I make it better?
- sakras 2y agoEssentially, unless you `fsync`, there's no guarantee that your data will be durably written to disk. This is because the operating system keeps data buffered in in-memory caches, so if the machine crashes you may lose some data. The `fsync` system call forces the data to be flushed from the in-memory OS cache to the disk. As far as I could tell, the Flush you use does not `fsync`.
- stym06 2y agoThanks for your input @sakras. I'll fix this