Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions accountsdb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ storage. Both require quiesced account writes, and relocation must wait for
borrowed readers. Platforms must support the reader synchronization required by
the store; initialization failures propagate to the caller.

Snapshot export directories are temporary. Keeper removes orphaned exports at
startup; retained snapshots live in the ledger.

Checksums cover persisted account state and its slot and superblock identity,
not volatile accounts or the transaction counter. A cached checksum describes a
previously published state. Fresh sampling requires writes and metadata updates
Expand Down
14 changes: 14 additions & 0 deletions accountsdb/src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ pub enum BackupOp {
}

impl AccountsDB {
/// Removes temporary snapshot exports left by a previous process.
///
/// Call during startup, before any snapshot archiver can use these paths.
/// The root must contain no unrelated `snapshot-*` entries.
pub fn cleanup_snapshots(&self) -> SnapshotResult<()> {
for entry in fs::read_dir(&self.root)? {
let entry = entry?;
if entry.file_name().to_str().is_some_and(|name| name.starts_with(PREFIX)) {
fs::remove_dir_all(entry.path())?;
}
}
Ok(())
}

/// Writes a superblock snapshot under `root`.
///
/// # Safety
Expand Down
1 change: 1 addition & 0 deletions keeper/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ impl KeeperBuilder {
pub async fn build(mut self, shutdown: &mut ShutdownManager) -> Result<Keeper> {
let ledger = Ledger::init(&self.ledger.directory, self.ledger.size_limit, shutdown)?;
let accountsdb = self.accountsdb(&ledger)?;
accountsdb.cleanup_snapshots()?;
let (caches, featureset) = self.prepopulate(&accountsdb, &ledger).await?;
metrics::init();
let epoch_schedule = self.epoch_schedule();
Expand Down
Loading