Skip to main content

TransactionLog

Trait TransactionLog 

Source
pub trait TransactionLog:
    Send
    + Sync
    + Debug {
    // Required methods
    fn append<'life0, 'async_trait>(
        &'life0 self,
        entry: LogEntry,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn read_after<'life0, 'async_trait>(
        &'life0 self,
        after: HlcTimestamp,
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<LogEntry>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn sweep<'life0, 'async_trait>(
        &'life0 self,
        policy: RetentionPolicy,
    ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn append_batch<'life0, 'async_trait>(
        &'life0 self,
        entries: Vec<LogEntry>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Per-deployment append-only log of every committed write.

One instance per deployment process; lives for the deployment’s lifetime. Entries are HLC-ordered and survive process restart (durability is the foundational contract — replication’s catch- up window relies on it).

§Contract

  • append is the durability sink. Returns only after the entry has been fsynced (or the implementation’s chosen durability point); subsequent read_after calls on the same instance must see the new entry.
  • read_after returns entries strictly greater than the given HLC, in ascending HLC order, up to limit. Used by replication for streaming tail-reads and catch-up on peer reconnection.
  • sweep removes entries that exceed the retention bounds. Returns the count of removed entries. Sweep is the only operation that DELETES from the log — append is the only operation that ADDS.

§Implementations

The canonical implementation is yeti_store::transaction_log::KvTransactionLog, backed by a dedicated KvBackend opened at {root_directory}/logs/transactions/{deployment_hash}/. Tests use the in-memory MemoryBackend under the same wrapper.

Required Methods§

Source

fn append<'life0, 'async_trait>( &'life0 self, entry: LogEntry, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Append a new entry. The entry’s hlc is assigned by the caller (typically from a HybridLogicalClock::now call at commit time). The log persists the entry verbatim.

§Errors
Source

fn read_after<'life0, 'async_trait>( &'life0 self, after: HlcTimestamp, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<LogEntry>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Read up to limit entries with hlc > after, in ascending HLC order. after = HlcTimestamp::ZERO reads from the beginning of the log.

§Errors
  • crate::error::YetiError::Internal if decoding any entry fails (indicates on-disk corruption or version skew).
  • Whatever the underlying storage backend returns from a scan.
Source

fn sweep<'life0, 'async_trait>( &'life0 self, policy: RetentionPolicy, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove entries that exceed the retention policy. Returns the number of entries removed.

§Errors

Whatever the underlying storage backend returns from scan + batch-delete operations.

Provided Methods§

Source

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

Append many entries in one call. Implementations should fuse the appends into a single batched backend write where possible — the default implementation falls back to a per-entry loop and is correct but pays one awaited backend call per entry.

Used by LoggingBackend::write_batch so a 100-record table batch produces one storage write per table + one batched write on the log, instead of 100 serial awaited log puts.

§Errors

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§