pub struct WalHeader {
pub magic: u64,
pub version: u16,
pub flags: u16,
pub epoch: u64,
pub writer_id: Uuid,
pub last_commit_lsn: u64,
pub last_entry_crc: u32,
pub entry_count: u64,
pub header_crc: u32,
}Expand description
WAL file header with epoch fencing
This header is stored in the first 64 bytes of every WAL file. It enables detection of concurrent writers and safe recovery.
Fields§
§magic: u64Magic number (0x534F4348444257 = “SOCHDBW”)
version: u16WAL format version
flags: u16Reserved flags
epoch: u64Epoch counter - incremented on each writer open
writer_id: UuidUUID of the current writer
last_commit_lsn: u64LSN of the last committed transaction
last_entry_crc: u32CRC of the last entry (for chain verification)
entry_count: u64Number of entries written in current epoch
header_crc: u32CRC32 of the header itself
Implementations§
Source§impl WalHeader
impl WalHeader
Sourcepub fn new_epoch(previous: &WalHeader) -> Self
pub fn new_epoch(previous: &WalHeader) -> Self
Create header for a new epoch (when taking over from previous writer)
Sourcepub fn update_last_entry_crc(&mut self, crc: u32)
pub fn update_last_entry_crc(&mut self, crc: u32)
Update last entry CRC (called after each write)
Sourcepub fn update_last_commit(&mut self, lsn: u64)
pub fn update_last_commit(&mut self, lsn: u64)
Update last commit LSN (called after each commit)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WalHeader
impl RefUnwindSafe for WalHeader
impl Send for WalHeader
impl Sync for WalHeader
impl Unpin for WalHeader
impl UnsafeUnpin for WalHeader
impl UnwindSafe for WalHeader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more