7 releases (unstable)
new 1.0.0-rc2 | Dec 13, 2024 |
---|---|
1.0.0-rc1 | Nov 6, 2024 |
0.12.0 | Oct 4, 2024 |
0.11.1 | Sep 2, 2024 |
0.10.1 | Jun 28, 2024 |
#2002 in Database interfaces
45 downloads per month
Used in 4 crates
(via spacetimedb-core)
35KB
462 lines
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
SnapshotRepository
which 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
ReconstructedSnapshot
inSnapshotRepository::read_snapshot
. TheReconstructedSnapshot
can 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_snapshot
andSnapshotRepository::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
ReconstructedSnapshot
into a live Spacetime datastore.
Dependencies
~16–27MB
~434K SLoC