Expand description
This crate implements capturing and restoring snapshots in SpacetimeDB.
A snapshot is an on-disk view of the committed state of a database at a particular transaction offset. Snapshots exist as an optimization over replaying the commitlog; when restoring to the most recent transaction, rather than replaying the commitlog from 0, we can reload the most recent snapshot, then replay only the suffix of the commitlog.
This crate is responsible for:
- The on-disk format of snapshots.
- A
SnapshotRepositorywhich contains multiple snapshots of a DB and can create and retrieve them. - Creating a snapshot given a view of a DB’s committed state in
SnapshotRepository::create_snapshot. - Reading an on-disk snapshot into memory as a
ReconstructedSnapshotinSnapshotRepository::read_snapshot. TheReconstructedSnapshotcan then be installed into a datastore. - Locating the most-recent snapshot of a DB, or the most recent snapshot not newer than a given tx offset,
in
SnapshotRepository::latest_snapshotandSnapshotRepository::latest_snapshot_older_than.
This crate is not responsible for:
- Determining when to capture snapshots.
- Deciding which snapshot to restore from after a restart.
- Replaying the suffix of the commitlog after restoring a snapshot.
- Transforming a
ReconstructedSnapshotinto a live Spacetime datastore.
Modules§
Structs§
- Reconstructed
Snapshot - Snapshot
- Snapshot
Repository - A repository of snapshots of a particular database instance.
- Snapshot
Size - Collect the size of the snapshot and the number of objects in it.
Enums§
- Object
Type - An object which may be associated with an error during snapshotting.
- Snapshot
Error
Constants§
- CURRENT_
MODULE_ ABI_ VERSION - ABI version of the module from which this snapshot was created, as [MAJOR, MINOR].
- CURRENT_
SNAPSHOT_ VERSION - Snapshot format version number.
- INVALID_
SNAPSHOT_ DIR_ EXT - File extension of snapshots which have been marked invalid by
SnapshotRepository::invalidate_newer_snapshots. - MAGIC
- Magic number for snapshot files: a point in spacetime.
- SNAPSHOT_
DIR_ EXT - File extension of snapshot directories.
- SNAPSHOT_
FILE_ EXT - File extension of snapshot files, which contain BSATN-encoded
Snapshots preceded byblake3::Hashes.