Skip to main content

VersionedLog

Struct VersionedLog 

Source
pub struct VersionedLog { /* private fields */ }
Expand description

A transaction log split into per-lease-version files for HA append isolation (see docs/design/log-and-transactor.md).

The active writer under lease version V appends only to {name}.v{V}.log (the pre-HA {name}.log reads as version 0). Readers merge the files in version order and drop any record in an older file whose t is at or past the first record of a later file: such records were appended by a deposed writer after a takeover and were never acknowledged, because acknowledgement re-verifies lease ownership after the durable append. A deposed writer therefore cannot corrupt or fork the log — its stale appends land in a file nobody considers current.

Implementations§

Source§

impl VersionedLog

Source

pub fn open( dir: impl AsRef<Path>, name: &str, write_version: u64, ) -> Result<Self, LogError>

Opens the log for writing under write_version, creating the version file if needed and dropping any torn tail it carries. Files of other versions are never modified.

§Errors

Returns an error if files cannot be read/created or a fully written record is corrupt.

Source

pub fn open_sealed( dir: impl AsRef<Path>, name: &str, write_version: u64, cipher: Arc<LogCipher>, ) -> Result<Self, LogError>

Opens the log for writing with record payloads sealed under cipher.

Every version file is read through the same cipher, and each frame is authenticated against the version of the file holding it.

§Errors

Returns an error if files cannot be read/created, a fully written record is corrupt, or a record cannot be authenticated.

Source

pub fn open_read_only( dir: impl AsRef<Path>, name: &str, ) -> Result<Self, LogError>

Opens the log read-only (independent inspection or backup); appends fail.

§Errors

Returns an error when the directory cannot be read or a fully written record is corrupt.

Source

pub fn open_read_only_sealed( dir: impl AsRef<Path>, name: &str, cipher: Arc<LogCipher>, ) -> Result<Self, LogError>

Opens the log read-only, opening sealed record payloads with cipher.

§Errors

Returns an error when the directory cannot be read, a fully written record is corrupt, or a record cannot be authenticated.

Source

pub fn exists(dir: impl AsRef<Path>, name: &str) -> bool

Reports whether any log file exists for this database.

Source

pub fn delete_all(dir: impl AsRef<Path>, name: &str) -> Result<(), LogError>

Deletes every version file for this database.

§Errors

Returns an error when a file cannot be removed.

Trait Implementations§

Source§

impl TransactionLog for VersionedLog

Source§

fn append(&self, record: &TxRecord) -> Result<(), LogError>

Durably appends exactly the next transaction. Read more
Source§

fn tx_range( &self, start: u64, end: Option<u64>, ) -> Result<Vec<TxRecord>, LogError>

Returns records in the half-open transaction range [start, end). Read more
Source§

fn append_async<'life0, 'life1, 'async_trait>( &'life0 self, record: &'life1 TxRecord, ) -> Pin<Box<dyn Future<Output = Result<(), LogError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Durably appends exactly the next transaction without blocking an async runtime worker. Synchronous logs use Self::append by default; storage-backed logs override this method and await their backend. Read more
Source§

fn append_batch_async<'life0, 'life1, 'async_trait>( &'life0 self, records: &'life1 [TxRecord], ) -> Pin<Box<dyn Future<Output = Result<(), LogError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Durably appends a contiguous run of transactions under a single durability boundary where the backend supports one (one fsync, one object, one database transaction), so group commit amortizes the per-append cost across the batch. records must be contiguous in t starting at the log’s next expected t; an empty slice is a no-op. The default appends them one at a time; batching backends override this. Read more
Source§

fn tx_range_async<'life0, 'async_trait>( &'life0 self, start: u64, end: Option<u64>, ) -> Pin<Box<dyn Future<Output = Result<Vec<TxRecord>, LogError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Asynchronous form of Self::tx_range. Read more
Source§

fn replay(&self) -> Result<Vec<TxRecord>, LogError>

Replays every committed record. Read more
Source§

fn replay_async<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<TxRecord>, LogError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Asynchronously replays every committed record. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.