pub struct TxnWalEntry {
pub record_type: WalRecordType,
pub txn_id: TxnId,
pub timestamp_us: u64,
pub key: Option<Vec<u8>>,
pub value: Option<Vec<u8>>,
pub table: Option<String>,
pub checksum: u32,
pub lsn: Lsn,
pub prev_lsn: Option<Lsn>,
pub page_id: Option<PageId>,
pub undo_info: Option<Vec<u8>>,
pub undo_next_lsn: Option<Lsn>,
}Expand description
WAL entry with ARIES transaction support
Extends standard WAL entries with ARIES-specific fields:
- LSN: Log Sequence Number for ordering and idempotent recovery
- prev_lsn: Previous LSN for this transaction (undo chain)
- undo_info: Before-image for undo operations
- page_id: Page affected by this operation
Fields§
§record_type: WalRecordTypeType of this WAL record
txn_id: TxnIdTransaction ID
timestamp_us: u64Timestamp in microseconds
key: Option<Vec<u8>>Optional key for data records
value: Option<Vec<u8>>Optional value for data records (after-image)
table: Option<String>Optional table name
checksum: u32CRC32 checksum
lsn: LsnARIES: Log Sequence Number (assigned when appended to WAL)
prev_lsn: Option<Lsn>ARIES: Previous LSN in this transaction’s chain (for undo)
page_id: Option<PageId>ARIES: Page ID affected by this record
undo_info: Option<Vec<u8>>ARIES: Before-image for undo (original value before update)
undo_next_lsn: Option<Lsn>ARIES: For CLRs, the next LSN to undo (skips compensated operations)
Implementations§
Source§impl TxnWalEntry
impl TxnWalEntry
Sourcepub const FORMAT_VERSION: u8 = 0x01
pub const FORMAT_VERSION: u8 = 0x01
Wire format version for forward/backward compatibility.
- V0 (0x00): Legacy 6-field format (record_type, txn_id, timestamp_us, key, value, table, checksum). ARIES fields are NOT serialized; from_bytes() defaults them to zero/None.
- V1 (0x01): Full ARIES format. All fields serialized including lsn, prev_lsn, page_id, undo_info, undo_next_lsn. Checksum covers ALL fields.
pub fn new_begin(txn_id: TxnId, timestamp_us: u64) -> Self
pub fn new_commit(txn_id: TxnId, timestamp_us: u64) -> Self
pub fn new_abort(txn_id: TxnId, timestamp_us: u64) -> Self
pub fn new_data( txn_id: TxnId, timestamp_us: u64, table: String, key: Vec<u8>, value: Option<Vec<u8>>, ) -> Self
Sourcepub fn new_aries_data(
txn_id: TxnId,
timestamp_us: u64,
table: String,
key: Vec<u8>,
value: Option<Vec<u8>>,
page_id: PageId,
prev_lsn: Option<Lsn>,
undo_info: Option<Vec<u8>>,
) -> Self
pub fn new_aries_data( txn_id: TxnId, timestamp_us: u64, table: String, key: Vec<u8>, value: Option<Vec<u8>>, page_id: PageId, prev_lsn: Option<Lsn>, undo_info: Option<Vec<u8>>, ) -> Self
Create a new ARIES-style data record with before-image for undo
Sourcepub fn new_clr(
txn_id: TxnId,
timestamp_us: u64,
table: String,
key: Vec<u8>,
value: Option<Vec<u8>>,
page_id: PageId,
prev_lsn: Lsn,
undo_next_lsn: Lsn,
) -> Self
pub fn new_clr( txn_id: TxnId, timestamp_us: u64, table: String, key: Vec<u8>, value: Option<Vec<u8>>, page_id: PageId, prev_lsn: Lsn, undo_next_lsn: Lsn, ) -> Self
Create a Compensation Log Record (CLR) for ARIES undo
CLRs are redo-only records that describe undo operations. They include undo_next_lsn which points to the next record to undo, skipping the compensated operation.
Sourcepub fn new_checkpoint_end(
timestamp_us: u64,
checkpoint_data: AriesCheckpointData,
) -> Result<Self, String>
pub fn new_checkpoint_end( timestamp_us: u64, checkpoint_data: AriesCheckpointData, ) -> Result<Self, String>
Create a checkpoint end record with recovery data
Sourcepub fn get_checkpoint_data(&self) -> Option<AriesCheckpointData>
pub fn get_checkpoint_data(&self) -> Option<AriesCheckpointData>
Extract checkpoint data from a CheckpointEnd record
Sourcepub fn compute_checksum(&mut self)
pub fn compute_checksum(&mut self)
Calculate and set checksum
Sourcepub fn verify_checksum(&self) -> bool
pub fn verify_checksum(&self) -> bool
Verify checksum
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serialize to bytes (versioned wire format)
Format V1 layout:
[version:1] [serialize_for_checksum payload] [crc32:4]Sourcepub fn from_bytes(data: &[u8]) -> Result<Self, String>
pub fn from_bytes(data: &[u8]) -> Result<Self, String>
Deserialize from bytes with proper error propagation
Supports both wire format versions:
- V0 (legacy): No version byte; first byte is a valid WalRecordType discriminant. ARIES fields default to zero/None.
- V1: First byte is 0x01 (FORMAT_VERSION). All ARIES fields deserialized.
Returns an error if:
- Data is too short
- Record type is invalid
- Data is truncated mid-field
- UTF-8 encoding is invalid for table name
- Checksum validation fails
Trait Implementations§
Source§impl Clone for TxnWalEntry
impl Clone for TxnWalEntry
Source§fn clone(&self) -> TxnWalEntry
fn clone(&self) -> TxnWalEntry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TxnWalEntry
impl Debug for TxnWalEntry
Source§impl<'de> Deserialize<'de> for TxnWalEntry
impl<'de> Deserialize<'de> for TxnWalEntry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for TxnWalEntry
impl RefUnwindSafe for TxnWalEntry
impl Send for TxnWalEntry
impl Sync for TxnWalEntry
impl Unpin for TxnWalEntry
impl UnsafeUnpin for TxnWalEntry
impl UnwindSafe for TxnWalEntry
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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