SIGN IN SIGN UP

server/replication: fsync frame data in wallog before writing header (#2200)

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
ac9c733b970f8a720981ad042a37d4d2ebda6d83
Committed by GitHub <noreply@github.com> on 12/19/2025, 9:14:17 AM