Skip to main content

read_new_segment

Function read_new_segment 

Source
pub fn read_new_segment(
    wal_path: &Path,
    from_byte: u64,
    durable_len: u64,
) -> Result<Option<(u64, u64, Vec<u8>)>>
Expand description

The next segment of wal_path to ship: bytes from from_byte up to at most durable_len, cut back to the last complete frame.

durable_len is what the engine reports as fsynced (SharedDb::durable_wal_position) — never the file’s length, which counts bytes still in the page cache. Returns (start, end, bytes), or None when there is no whole frame to ship (nothing new, the file is missing or shorter than from_byte, or only part of a frame is there).

§Errors

An I/O error reading the file, or InvalidData when the bytes at from_byte are long enough to hold a frame but are not one — the cursor is not on a frame boundary, or the WAL is corrupt — which a retry cannot fix and must not be shipped.