Skip to content

Commit

Permalink
fix: order of guarded and non-guarded db migration (near#8672)
Browse files Browse the repository at this point in the history
In near#8617 we introduced new DB migration (deprecating Peers column). But before it we had another migration indicating creation of flat storage columns, currently guarded by compilation flag.

Actually, we should put "peers" migration **before** "flat state" migration, because for nodes which don't have flat state enabled, intermediate version in `match` will be missing. We didn't see it because we also didn't update `DB_VERSION`, which essentially means that nodes didn't trigger any migrations yet.

Here I also bump `DB_VERSION`, so nodes will run "peers" migration and then "flat state" migration if compilation flag is enabled. The only outcome is that our custom nodes which have flat state **will not** run "peers" migration, but this is fine.

cc @saketh-are
  • Loading branch information
Longarithm authored and nikurt committed Mar 15, 2023
1 parent eef6a12 commit dfebbcf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/store/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub type DbVersion = u32;

/// Current version of the database.
pub const DB_VERSION: DbVersion =
if cfg!(feature = "protocol_feature_flat_state") { 35 } else { 34 };
if cfg!(feature = "protocol_feature_flat_state") { 36 } else { 35 };

/// Database version at which point DbKind was introduced.
const DB_VERSION_WITH_KIND: DbVersion = 34;
Expand Down
4 changes: 2 additions & 2 deletions core/store/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,11 @@ pub fn migrate_33_to_34(store: &Store, mut is_node_archival: bool) -> anyhow::Re
Ok(())
}

/// Migrates the database from version 35 to 36.
/// Migrates the database from version 34 to 35.
///
/// This involves deleting contents of Peers column which is now
/// deprecated and no longer used.
pub fn migrate_35_to_36(store: &Store) -> anyhow::Result<()> {
pub fn migrate_34_to_35(store: &Store) -> anyhow::Result<()> {
let mut update = store.store_update();
update.delete_all(DBCol::_Peers);
update.commit()?;
Expand Down
6 changes: 3 additions & 3 deletions nearcore/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ impl<'a> near_store::StoreMigrator for Migrator<'a> {
33 => {
near_store::migrations::migrate_33_to_34(store, self.config.client_config.archive)
}
34 => near_store::migrations::migrate_34_to_35(store),
#[cfg(feature = "protocol_feature_flat_state")]
34 => {
tracing::info!(target: "migrations", "Migrating DB version from 34 to 35. Flat storage data will be created on disk.");
35 => {
tracing::info!(target: "migrations", "Migrating DB version from 35 to 36. Flat storage data will be created on disk.");
tracing::info!(target: "migrations", "It will happen in parallel with regular block processing. ETA is 5h for RPC node and 10h for archival node.");
Ok(())
}
35 => near_store::migrations::migrate_35_to_36(store),
DB_VERSION.. => unreachable!(),
}
}
Expand Down

0 comments on commit dfebbcf

Please sign in to comment.