pub struct FileTransitionLog { /* private fields */ }Expand description
Append-only, line-oriented transitions log backed by a single file.
Appending costs one write and one fsync regardless of how many
entries the log already holds. Retention policies compact it through
compact_log_entries, which
writes the retained entries to <path>.compact, syncs it and renames it
over the log, so the journal on disk stays bounded (issue #195).
§Durability
With sync_on_append enabled (the default) every
append_log_entry returns
only after the entry has reached stable storage, which is what makes
the write-ahead ordering of the transactions layer meaningful: a
transition is always durable before the data-store write it
describes is reported as committed. Disabling it trades that
guarantee for throughput — the log is then durable only as far as
the last flush_log.
An interrupted append can leave a partial final line. Opening the log, or reading, appending or flushing after a writer I/O error, repairs that suffix before proceeding. A failed repair is retried on the next operation. Complete records remain intact, including records written before an error was returned; callers must discover an uncertain transaction’s outcome rather than blindly retry it. Repair scans backwards with an 8 KiB buffer; successful operations do not rescan. This framing protocol assumes storage honors flush and does not prove device-sector atomicity after power loss.
Implementations§
Source§impl FileTransitionLog
impl FileTransitionLog
Sourcepub fn open<P: AsRef<Path>>(path: P) -> Result<Self, LinkError>
pub fn open<P: AsRef<Path>>(path: P) -> Result<Self, LinkError>
Opens (creating if needed) the log at path, discarding a
trailing entry left half-written by a crash.
Sourcepub fn open_exclusive<P: AsRef<Path>>(path: P) -> Result<Self, LinkError>
pub fn open_exclusive<P: AsRef<Path>>(path: P) -> Result<Self, LinkError>
Holds the conventional sidecar lock until drop. Contention fails fast; all writers must follow the same advisory locking convention.
Sourcepub fn sync_on_append(&self) -> bool
pub fn sync_on_append(&self) -> bool
Whether every append is fsynced. Enabled by default.
Sourcepub fn set_sync_on_append(&mut self, value: bool)
pub fn set_sync_on_append(&mut self, value: bool)
Turns per-append fsync on or off — see the durability notes.
Trait Implementations§
Source§impl Debug for FileTransitionLog
impl Debug for FileTransitionLog
Source§impl ReplaceableTransitionLogStore for FileTransitionLog
impl ReplaceableTransitionLogStore for FileTransitionLog
Source§fn replace_log_entries(&mut self, entries: &[String]) -> Result<bool, LinkError>
fn replace_log_entries(&mut self, entries: &[String]) -> Result<bool, LinkError>
Source§fn supports_replacement(&self) -> bool
fn supports_replacement(&self) -> bool
Source§impl TransitionLogStore for FileTransitionLog
impl TransitionLogStore for FileTransitionLog
Source§fn supports_durable_flush(&self) -> bool
fn supports_durable_flush(&self) -> bool
Source§fn supports_compaction(&self) -> bool
fn supports_compaction(&self) -> bool
compact_log_entries can rewrite
the durable journal. Retention uses it to bound the journal on disk;
logs without it keep every entry, as before.Source§fn compact_log_entries(&mut self, entries: &[String]) -> Result<(), LinkError>
fn compact_log_entries(&mut self, entries: &[String]) -> Result<(), LinkError>
entries, the
retained journal. After a crash the log holds either the old or the
new journal, never a mixture. Called only between transactions and
only when supports_compaction is true.