Skip to main content

WalRecorder

Struct WalRecorder 

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

Implementations§

Source§

impl WalRecorder

Source

pub fn new(wal: Arc<Wal>) -> Self

Source

pub fn new_with_mirror( wal: Arc<Wal>, mirror: Option<Arc<dyn WalMirror>>, ) -> Self

Source

pub fn wal(&self) -> &Arc<Wal>

Underlying log handle. Exposed so admin paths (Database::checkpoint_to, truncate_up_to) can hit the WAL directly without going through the recorder’s transaction state machine.

Source

pub fn arm(&self) -> Result<(), WalError>

Mark the recorder as inside a query critical section. No WAL I/O happens here — Wal::begin is deferred until the first mutation event fires. A pure read query that never produces a MutationEvent therefore costs the WAL nothing: no record allocation, no buffer drain, no fsync.

Errors with WalError::Poisoned if a prior failure has poisoned the recorder, or if the host is double-arming (arm already in effect).

Source

pub fn commit(&self) -> Result<WroteCommit, WalError>

Append a TxCommit for the active transaction (if any) and clear the armed/active state.

Returns:

  • WroteCommit::Yes when a lazy TxBegin had been issued and a matching TxCommit was now appended. The host should flush() next under SyncMode::PerCommit.
  • WroteCommit::No when no mutations fired during the query and no records were written. The host should skip flush().
Source

pub fn abort(&self) -> Result<bool, WalError>

Append a TxAbort for the active transaction (if any) and clear the armed/active state. Returns Ok(true) when the live graph may have observed mutations and should be quarantined, Ok(false) when the query never mutated anything.

Source

pub fn flush(&self) -> Result<(), WalError>

Flush the WAL — write the pending buffer to the OS and (under SyncMode::PerCommit) fsync.

Source

pub fn force_fsync(&self) -> Result<(), WalError>

Force the underlying WAL to write, fsync, and advance its durable fence regardless of the configured sync mode. Admin paths use this when they need a durability point immediately.

Source

pub fn checkpoint_marker(&self, snapshot_lsn: Lsn) -> Result<Lsn, WalError>

Append a Checkpoint marker. Used by the checkpoint admin path after a successful snapshot rename — the marker doubles as the log-side fence the next replay will trust.

Source

pub fn truncate_up_to(&self, fence_lsn: Lsn) -> Result<(), WalError>

Drop sealed segments at or below fence_lsn. Forwards to Wal::truncate_up_to.

Source

pub fn is_poisoned(&self) -> bool

True iff the recorder has already failed an append, or the background flusher has latched a failure. Cheap to poll under the store lock.

Source

pub fn poison(&self, reason: impl Into<String>)

Quarantine the recorder after the host detects that the live in-memory graph may no longer match durable state. Once poisoned, future query arms fail until the database is restarted from a snapshot + WAL.

Trait Implementations§

Source§

impl MutationRecorder for WalRecorder

Source§

fn record(&self, event: &MutationEvent)

Source§

fn poisoned(&self) -> Option<String>

Sticky failure flag for durability-shaped recorders. 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, 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.