pub struct WalRecorder { /* private fields */ }Expand description
Adapter that lets a Wal act as a MutationRecorder on
lora_store::InMemoryGraph::set_mutation_recorder.
Implementations§
Source§impl WalRecorder
impl WalRecorder
pub fn new(wal: Arc<Wal>) -> Self
Sourcepub fn wal(&self) -> &Arc<Wal>
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.
Sourcepub fn arm(&self) -> Result<(), WalError>
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).
Sourcepub fn commit(&self) -> Result<WroteCommit, WalError>
pub fn commit(&self) -> Result<WroteCommit, WalError>
Append a TxCommit for the active transaction (if any) and
clear the armed/active state.
Returns:
WroteCommit::Yeswhen a lazyTxBeginhad been issued and a matchingTxCommitwas now appended. The host shouldflush()next underSyncMode::PerCommit.WroteCommit::Nowhen no mutations fired during the query and no records were written. The host should skipflush().
Sourcepub fn abort(&self) -> Result<bool, WalError>
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 an abort
record was actually written, Ok(false) when the query never
got far enough to issue a TxBegin.
Sourcepub fn flush(&self) -> Result<(), WalError>
pub fn flush(&self) -> Result<(), WalError>
Flush the WAL — write the pending buffer to the OS and
(under SyncMode::PerCommit) fsync.
Sourcepub fn force_fsync(&self) -> Result<(), WalError>
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.
Sourcepub fn checkpoint_marker(&self, snapshot_lsn: Lsn) -> Result<Lsn, WalError>
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.
Sourcepub fn truncate_up_to(&self, fence_lsn: Lsn) -> Result<(), WalError>
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.
Sourcepub fn is_poisoned(&self) -> bool
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 engine mutex.