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
impl VersionedLog
Sourcepub fn open(
dir: impl AsRef<Path>,
name: &str,
write_version: u64,
) -> Result<Self, LogError>
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.
Sourcepub fn open_read_only(
dir: impl AsRef<Path>,
name: &str,
) -> Result<Self, LogError>
pub fn open_read_only( dir: impl AsRef<Path>, name: &str, ) -> Result<Self, LogError>
Opens the log read-only (offline inspection, backup); appends fail.
§Errors
Returns an error when the directory cannot be read or a fully written record is corrupt.
Trait Implementations§
Source§impl TransactionLog for VersionedLog
impl TransactionLog for VersionedLog
Source§fn append(&self, record: &TxRecord) -> Result<(), LogError>
fn append(&self, record: &TxRecord) -> Result<(), LogError>
Source§fn tx_range(
&self,
start: u64,
end: Option<u64>,
) -> Result<Vec<TxRecord>, LogError>
fn tx_range( &self, start: u64, end: Option<u64>, ) -> Result<Vec<TxRecord>, LogError>
[start, end). Read moreSource§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,
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,
Self::append by default;
storage-backed logs override this method and await their backend. Read more