Skip to content

Commit

Permalink
If LMDB copy+compact fails, erase the partial output
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedilger committed Nov 8, 2024
1 parent c977f56 commit b291079
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gossip-lib/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ impl Storage {
// Copy to backup file, compacting
tracing::info!("Compacting LMDB...");
if let Err(_) = env.copy_to_file(&backup, heed::CompactionOption::Enabled) {
// Erase the attempt
std::fs::remove_file(&backup)?;

// Just give up on compacting
return Ok(());
}
Expand All @@ -226,7 +229,7 @@ impl Storage {
// Move the backup to the data
std::fs::rename(&backup, &data)?;

// Rmeove the old
// Remove the old
std::fs::remove_file(&old)?;

Ok(())
Expand Down

0 comments on commit b291079

Please sign in to comment.