Do not upgrade db_version on metadata reading failure. (#11081)

This commit is contained in:
cheme
2022-03-22 10:53:49 +01:00
committed by GitHub
parent 330acd47e6
commit 61f1b2e6ab
4 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -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))?;
}
}
+1
View File
@@ -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)?)
},