Skip to content

Commit 1de658a

Browse files
authored
fix: speed up void db migration (#5452)
1 parent 7cf2a5d commit 1de658a

File tree

4 files changed

+235
-283
lines changed

4 files changed

+235
-283
lines changed

src/db/migration/db_migration.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,33 +65,34 @@ impl DbMigration {
6565
let latest_db_version = get_latest_versioned_database(&self.chain_data_path())?
6666
.unwrap_or_else(|| FOREST_VERSION.clone());
6767

68-
info!(
69-
"Migrating database from version {} to {}",
70-
latest_db_version, *FOREST_VERSION
71-
);
72-
7368
let target_db_version = &FOREST_VERSION;
7469

7570
let migrations = create_migration_chain(&latest_db_version, target_db_version)?;
7671

7772
for migration in migrations {
73+
info!(
74+
"Migrating database from version {} to {}",
75+
migration.from(),
76+
migration.to()
77+
);
78+
let start = std::time::Instant::now();
7879
migration.migrate(&self.chain_data_path(), &self.config)?;
80+
info!(
81+
"Successfully migrated from version {} to {}, took {}",
82+
migration.from(),
83+
migration.to(),
84+
humantime::format_duration(std::time::Instant::now() - start),
85+
);
7986
}
8087

81-
info!(
82-
"Migration to version {} complete",
83-
target_db_version.to_string()
84-
);
85-
8688
Ok(())
8789
}
8890
}
8991

9092
#[cfg(test)]
9193
mod tests {
92-
use crate::db::db_mode::FOREST_DB_DEV_MODE;
93-
9494
use super::*;
95+
use crate::db::db_mode::FOREST_DB_DEV_MODE;
9596

9697
#[test]
9798
fn test_migration_not_required_no_chain_path() {

0 commit comments

Comments
 (0)