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.