Skip to content

Commit

Permalink
Do not upgrade db_version on metadata reading failure. (paritytech#11081
Browse files Browse the repository at this point in the history
)
  • Loading branch information
cheme authored Mar 22, 2022
1 parent c9fc99d commit 715d004
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ sc-state-db = { version = "0.10.0-dev", path = "../state-db" }
sp-trie = { version = "6.0.0", path = "../../primitives/trie" }
sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" }
sp-database = { version = "4.0.0-dev", path = "../../primitives/database" }
parity-db = { version = "0.3.8", optional = true }
parity-db = { version = "0.3.9", optional = true }

[dev-dependencies]
sp-tracing = { version = "5.0.0", path = "../../primitives/tracing" }
Expand Down
2 changes: 1 addition & 1 deletion client/db/src/parity_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub fn open<H: Clone + AsRef<[u8]>>(
if upgrade {
log::info!("Upgrading database metadata.");
if let Some(meta) = parity_db::Options::load_metadata(path)? {
config.write_metadata(path, &meta.salt)?;
config.write_metadata_with_version(path, &meta.salt, Some(meta.version))?;
}
}

Expand Down
1 change: 1 addition & 0 deletions client/db/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ fn open_parity_db<Block: BlockT>(path: &Path, db_type: DatabaseType, create: boo
match crate::parity_db::open(path, db_type, create, false) {
Ok(db) => Ok(db),
Err(parity_db::Error::InvalidConfiguration(_)) => {
log::warn!("Invalid parity db configuration, attempting database metadata update.");
// Try to update the database with the new config
Ok(crate::parity_db::open(path, db_type, create, true)?)
},
Expand Down

0 comments on commit 715d004

Please sign in to comment.