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: u16Payload format version; must equal ENGINE_SNAPSHOT_FORMAT_VERSION.
group_id: RaftGroupIdThe consensus group this snapshot belongs to.
last_included: LogPositionLast log position whose effects the image includes.
commit_ts: Option<HlcTimestamp>Commit timestamp recorded at last_included, when any command has
been applied.
epoch: u64MVCC snapshot epoch (the core’s visible watermark at capture).
cluster_id: ClusterIdOwning cluster (identity of the replicated database).
database_id: DatabaseIdReplicated logical database.
catalog_version: u64Catalog 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: u16On-disk WAL format version at capture (verified on install).
storage_mode_format: u16Storage-mode marker format version at capture (verified on install).
Implementations§
Source§impl EngineSnapshot
impl EngineSnapshot
Sourcepub fn capture(
db: &Database,
group_id: RaftGroupId,
last_included: LogPosition,
commit_ts: Option<HlcTimestamp>,
) -> Result<Self>
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.
Sourcepub fn encode(&self) -> Result<Vec<u8>>
pub fn encode(&self) -> Result<Vec<u8>>
Serializes deterministically (bincode over the versioned struct).
Sourcepub fn decode(bytes: &[u8]) -> Result<Self>
pub fn decode(bytes: &[u8]) -> Result<Self>
Decodes, failing closed on an unknown format version.
Sourcepub fn validate(
&self,
group_id: &RaftGroupId,
cluster_id: &ClusterId,
database_id: &DatabaseId,
) -> Result<()>
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.
Sourcepub fn stage_into(&self, staging: &Path, node_id: NodeId) -> Result<()>
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.
Sourcepub fn validate_staged(&self, staging: &Path) -> Result<()>
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.
Sourcepub fn install(
self,
live: &mut Option<Arc<Database>>,
node_id: NodeId,
) -> Result<()>
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
impl Clone for EngineSnapshot
Source§fn clone(&self) -> EngineSnapshot
fn clone(&self) -> EngineSnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EngineSnapshot
impl Debug for EngineSnapshot
Source§impl<'de> Deserialize<'de> for EngineSnapshot
impl<'de> Deserialize<'de> for EngineSnapshot
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for EngineSnapshot
impl RefUnwindSafe for EngineSnapshot
impl Send for EngineSnapshot
impl Sync for EngineSnapshot
impl Unpin for EngineSnapshot
impl UnsafeUnpin for EngineSnapshot
impl UnwindSafe for EngineSnapshot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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