Skip to main content

EngineSnapshot

Struct EngineSnapshot 

Source
pub struct EngineSnapshot {
    pub version: u16,
    pub group_id: RaftGroupId,
    pub last_included: LogPosition,
    pub commit_ts: Option<HlcTimestamp>,
    pub epoch: u64,
    pub cluster_id: ClusterId,
    pub database_id: DatabaseId,
    pub catalog_version: u64,
    pub tables: Vec<EngineSnapshotTable>,
    pub files: Vec<EngineSnapshotFile>,
    pub wal_format: u16,
    pub storage_mode_format: u16,
}
Expand description

The engine apply sink’s snapshot payload (spec section 11.5): applied state at one log boundary, plus everything needed to verify and semantically validate it before it replaces a replica’s state.

Fields§

§version: u16

Payload format version; must equal ENGINE_SNAPSHOT_FORMAT_VERSION.

§group_id: RaftGroupId

The consensus group this snapshot belongs to.

§last_included: LogPosition

Last log position whose effects the image includes.

§commit_ts: Option<HlcTimestamp>

Commit timestamp recorded at last_included, when any command has been applied.

§epoch: u64

MVCC snapshot epoch (the core’s visible watermark at capture).

§cluster_id: ClusterId

Owning cluster (identity of the replicated database).

§database_id: DatabaseId

Replicated logical database.

§catalog_version: u64

Catalog command version at capture (S1F-001).

§tables: Vec<EngineSnapshotTable>

Table/run manifest: every live table and its visible row count.

§files: Vec<EngineSnapshotFile>

Every required file (catalog checkpoint, manifests, run/index files, WAL), hashed.

§wal_format: u16

On-disk WAL format version at capture (verified on install).

§storage_mode_format: u16

Storage-mode marker format version at capture (verified on install).

Implementations§

Source§

impl EngineSnapshot

Source

pub fn capture( db: &Database, group_id: RaftGroupId, last_included: LogPosition, commit_ts: Option<HlcTimestamp>, ) -> Result<Self>

Captures the live core’s applied state. The caller (the apply sink) holds the apply mutex, so no replicated command is applying and the read-only core is quiescent: the copied files and the recorded position describe one log boundary.

Source

pub fn encode(&self) -> Result<Vec<u8>>

Serializes deterministically (bincode over the versioned struct).

Source

pub fn decode(bytes: &[u8]) -> Result<Self>

Decodes, failing closed on an unknown format version.

Source

pub fn validate( &self, group_id: &RaftGroupId, cluster_id: &ClusterId, database_id: &DatabaseId, ) -> Result<()>

Spec step “verify hashes and versions”: the group and database identity must match this replica, every file hash must hold, and the recorded format versions must be readable by this build.

Source

pub fn stage_into(&self, staging: &Path, node_id: NodeId) -> Result<()>

Spec step “download to staging”: write the image into the (fresh, empty) staging directory, fsyncing every file. The storage-mode marker is rewritten with the LOCAL node identity: the image came from a peer replica of the same database, and a marker must name its owner.

Source

pub fn validate_staged(&self, staging: &Path) -> Result<()>

Spec step “open and semantically validate”: open the staged image through the offline-validation API (read-only, any storage mode) and confirm every manifest table mounts with the recorded visible row count at the snapshot epoch.

Source

pub fn install( self, live: &mut Option<Arc<Database>>, node_id: NodeId, ) -> Result<()>

Spec steps “pause apply → atomically replace → resume → remove old state”. The apply mutex the caller holds is the pause. The staged, validated image is swapped with the live root through the rename idiom of crate::replication::ReplicationSnapshot::install_validated — never installed over live state: the live core is shut down first (refusing with MongrelError::Conflict while other owners hold it, leaving live untouched), the old root is renamed aside and retained until success, the replica is reopened as the cluster runtime, and the old tree is removed. On success live holds the reopened database; on a pre-shutdown failure it is unchanged.

Trait Implementations§

Source§

impl Clone for EngineSnapshot

Source§

fn clone(&self) -> EngineSnapshot

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EngineSnapshot

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for EngineSnapshot

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for EngineSnapshot

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.