Fsync frame data in wallog before writing header
Currently in logger.rs we are not issuing any fsyncs at all. We do `flush()` in `write_header()` but this is a no-op on Unix because there are no userspace buffers to flush since `write_all_at()` writes directly to kernel. Not fsyncing can cause the following bug: - We write X frames - We write wallog header (containing frame count X) - Kernel reorders writes so that header has been written out but not all of the frame data - Crash - Sqld starts up, reads wallog header which claims X frames exist in wallog, but only Y frames (Y < X) have been written - short read in read_frame_byte_offset_mut() returns an error and crashes the server It's also important to sync after writing frames but before writing the header so that there is no write reordering scenario where the header is persistent before the frame data is.
J
Jussi Saurio committed
214baf10200f6e02cd42ac81f4de609667de8b53
Parent: 2d50cd0