16 releases (7 stable)
| 1.3.0 | Aug 1, 2025 |
|---|---|
| 1.2.0 | Jun 17, 2025 |
| 1.1.2 | May 9, 2025 |
| 1.0.1 | Mar 25, 2025 |
| 0.10.1 | Jun 28, 2024 |
#3 in #commit-log
Used in 4 crates
(2 directly)
83KB
1.5K
SLoC
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.
⚠️ Internal Crate ⚠️
This crate is intended for internal use only. It is not stable and may change without notice.
Dependencies
~31–51MB
~744K SLoC