Skip to content

Commit

Permalink
fix(core): only resize db if migration is required (#4792)
Browse files Browse the repository at this point in the history
Description
---
Adds conditional to only increase database size if migration is required

Motivation and Context
---
A new database (cucumber, functional tests) has no inputs and so migration is not required.
Ref #4791 

How Has This Been Tested?
---
  • Loading branch information
sdbondi committed Oct 11, 2022
1 parent 702658c commit 4811a57
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs
Expand Up @@ -2618,7 +2618,7 @@ fn run_migrations(db: &LMDBDatabase) -> Result<(), ChainStorageError> {
Ok(())
}

// TODO: remove
// TODO: this is a temporary fix, remove
mod tari_script_execution_stack_bug_migration {
use serde::{Deserialize, Serialize};
use tari_common_types::types::{ComSignature, PublicKey};
Expand All @@ -2632,6 +2632,13 @@ mod tari_script_execution_stack_bug_migration {
};

pub fn migrate(db: &LMDBDatabase) -> Result<(), ChainStorageError> {
{
let txn = db.read_transaction()?;
// Only perform migration if necessary
if lmdb_len(&txn, &db.inputs_db)? == 0 {
return Ok(());
}
}
unsafe {
LMDBStore::resize(&db.env, &LMDBConfig::new(0, 1024 * 1024 * 1024, 0))?;
}
Expand Down

0 comments on commit 4811a57

Please sign in to comment.