mirror of
https://github.com/tendermint/tendermint.git
synced 2026-07-27 18:42:46 +00:00
d71d1394ec48f89fab50bf8e592e3de6200b5b94
short: flushing the bufio buffer is not enough to ensure data consistency. long: Saving an entry to the WAL calls writeLine to append data to the autofile group backing the WAL, then calls group.Flush() to flush that data to persistent storage. group.Flush() in turn proxies to headBuf.flush(), flushing the active bufio.BufferedWriter. However, BufferedWriter wraps a Writer, not another BufferedWriter, and the way it flushes is by calling io.Writer.Write() to clear the BufferedWriter's buffer. The io.Writer we're wrapping here is AutoFile, whose Write method calls os.File.Write(), performing an unbuffered write to the operating system, where, I assume, it sits in the OS buffers awaiting sync. This means that Wal.Save does not, in fact, ensure the saved operation is synced to disk before returning.
Languages
Go
85.9%
TeX
7.2%
TLA
4.9%
Shell
0.6%
Python
0.5%
Other
0.8%