Disable WAL (#1765)
* Disable WAL * Make WAL optional * Fix tests. * Update cli.rs
This commit is contained in:
parent
29e07755e9
commit
57faa37623
@ -176,6 +176,7 @@ impl Client {
|
||||
let mut db_config = DatabaseConfig::with_columns(DB_NO_OF_COLUMNS);
|
||||
db_config.cache_size = config.db_cache_size;
|
||||
db_config.compaction = config.db_compaction.compaction_profile();
|
||||
db_config.wal = config.db_wal;
|
||||
|
||||
let db = Arc::new(Database::open(&db_config, &path.to_str().unwrap()).expect("Error opening database"));
|
||||
let chain = Arc::new(BlockChain::new(config.blockchain, &gb, db.clone()));
|
||||
|
@ -101,6 +101,8 @@ pub struct ClientConfig {
|
||||
pub db_cache_size: Option<usize>,
|
||||
/// State db compaction profile
|
||||
pub db_compaction: DatabaseCompactionProfile,
|
||||
/// Should db have WAL enabled?
|
||||
pub db_wal: bool,
|
||||
/// Operating mode
|
||||
pub mode: Mode,
|
||||
/// Type of block verifier used by client.
|
||||
|
@ -76,6 +76,7 @@ pub struct ImportBlockchain {
|
||||
pub format: Option<DataFormat>,
|
||||
pub pruning: Pruning,
|
||||
pub compaction: DatabaseCompactionProfile,
|
||||
pub wal: bool,
|
||||
pub mode: Mode,
|
||||
pub tracing: Switch,
|
||||
pub vm_type: VMType,
|
||||
@ -91,6 +92,7 @@ pub struct ExportBlockchain {
|
||||
pub format: Option<DataFormat>,
|
||||
pub pruning: Pruning,
|
||||
pub compaction: DatabaseCompactionProfile,
|
||||
pub wal: bool,
|
||||
pub mode: Mode,
|
||||
pub tracing: Switch,
|
||||
pub from_block: BlockID,
|
||||
@ -129,7 +131,7 @@ fn execute_import(cmd: ImportBlockchain) -> Result<String, String> {
|
||||
try!(execute_upgrades(&cmd.dirs, genesis_hash, spec.fork_name.as_ref(), algorithm, cmd.compaction.compaction_profile()));
|
||||
|
||||
// prepare client config
|
||||
let client_config = to_client_config(&cmd.cache_config, &cmd.dirs, genesis_hash, cmd.mode, cmd.tracing, cmd.pruning, cmd.compaction, cmd.vm_type, "".into(), spec.fork_name.as_ref());
|
||||
let client_config = to_client_config(&cmd.cache_config, &cmd.dirs, genesis_hash, cmd.mode, cmd.tracing, cmd.pruning, cmd.compaction, cmd.wal, cmd.vm_type, "".into(), spec.fork_name.as_ref());
|
||||
|
||||
// build client
|
||||
let service = try!(ClientService::start(
|
||||
@ -240,7 +242,7 @@ fn execute_export(cmd: ExportBlockchain) -> Result<String, String> {
|
||||
try!(execute_upgrades(&cmd.dirs, genesis_hash, spec.fork_name.as_ref(), algorithm, cmd.compaction.compaction_profile()));
|
||||
|
||||
// prepare client config
|
||||
let client_config = to_client_config(&cmd.cache_config, &cmd.dirs, genesis_hash, cmd.mode, cmd.tracing, cmd.pruning, cmd.compaction, VMType::default(), "".into(), spec.fork_name.as_ref());
|
||||
let client_config = to_client_config(&cmd.cache_config, &cmd.dirs, genesis_hash, cmd.mode, cmd.tracing, cmd.pruning, cmd.compaction, cmd.wal, VMType::default(), "".into(), spec.fork_name.as_ref());
|
||||
|
||||
let service = try!(ClientService::start(
|
||||
client_config,
|
||||
|
@ -210,8 +210,8 @@ Footprint Options:
|
||||
--cache-size MB Set total amount of discretionary memory to use for
|
||||
the entire system, overrides other cache and queue
|
||||
options.
|
||||
|
||||
Database Options:
|
||||
--fast-and-loose Disables DB WAL, which gives a significant speed up
|
||||
but means an unclean exit is unrecoverable.
|
||||
--db-compaction TYPE Database compaction type. TYPE may be one of:
|
||||
ssd - suitable for SSDs and fast HDDs;
|
||||
hdd - suitable for slow HDDs [default: ssd].
|
||||
@ -314,6 +314,7 @@ pub struct Args {
|
||||
pub flag_cache_size_queue: u32,
|
||||
pub flag_cache_size: Option<u32>,
|
||||
pub flag_cache: Option<u32>,
|
||||
pub flag_fast_and_loose: bool,
|
||||
|
||||
pub flag_no_jsonrpc: bool,
|
||||
pub flag_jsonrpc_interface: String,
|
||||
|
@ -81,6 +81,7 @@ impl Configuration {
|
||||
let spec = try!(self.chain().parse());
|
||||
let tracing = try!(self.args.flag_tracing.parse());
|
||||
let compaction = try!(self.args.flag_db_compaction.parse());
|
||||
let wal = !self.args.flag_fast_and_loose;
|
||||
let enable_network = self.enable_network(&mode);
|
||||
let geth_compatibility = self.args.flag_geth;
|
||||
let signer_port = self.signer_port();
|
||||
@ -129,6 +130,7 @@ impl Configuration {
|
||||
format: None,
|
||||
pruning: pruning,
|
||||
compaction: compaction,
|
||||
wal: wal,
|
||||
mode: mode,
|
||||
tracing: tracing,
|
||||
vm_type: vm_type,
|
||||
@ -144,6 +146,7 @@ impl Configuration {
|
||||
format: None,
|
||||
pruning: pruning,
|
||||
compaction: compaction,
|
||||
wal: wal,
|
||||
mode: mode,
|
||||
tracing: tracing,
|
||||
from_block: try!(to_block_id(&self.args.flag_from)),
|
||||
@ -175,6 +178,7 @@ impl Configuration {
|
||||
mode: mode,
|
||||
tracing: tracing,
|
||||
compaction: compaction,
|
||||
wal: wal,
|
||||
vm_type: vm_type,
|
||||
enable_network: enable_network,
|
||||
geth_compatibility: geth_compatibility,
|
||||
@ -613,6 +617,7 @@ mod tests {
|
||||
format: None,
|
||||
pruning: Default::default(),
|
||||
compaction: Default::default(),
|
||||
wal: true,
|
||||
mode: Default::default(),
|
||||
tracing: Default::default(),
|
||||
vm_type: VMType::Interpreter,
|
||||
@ -632,6 +637,7 @@ mod tests {
|
||||
pruning: Default::default(),
|
||||
format: Default::default(),
|
||||
compaction: Default::default(),
|
||||
wal: true,
|
||||
mode: Default::default(),
|
||||
tracing: Default::default(),
|
||||
from_block: BlockID::Number(1),
|
||||
@ -669,6 +675,7 @@ mod tests {
|
||||
mode: Default::default(),
|
||||
tracing: Default::default(),
|
||||
compaction: Default::default(),
|
||||
wal: true,
|
||||
vm_type: Default::default(),
|
||||
enable_network: true,
|
||||
geth_compatibility: false,
|
||||
|
@ -193,6 +193,7 @@ pub fn to_client_config(
|
||||
tracing: Switch,
|
||||
pruning: Pruning,
|
||||
compaction: DatabaseCompactionProfile,
|
||||
wal: bool,
|
||||
vm_type: VMType,
|
||||
name: String,
|
||||
fork_name: Option<&String>,
|
||||
@ -215,6 +216,7 @@ pub fn to_client_config(
|
||||
client_config.tracing.enabled = tracing;
|
||||
client_config.pruning = pruning.to_algorithm(dirs, genesis_hash, fork_name);
|
||||
client_config.db_compaction = compaction;
|
||||
client_config.db_wal = wal;
|
||||
client_config.vm_type = vm_type;
|
||||
client_config.name = name;
|
||||
client_config
|
||||
|
@ -163,6 +163,7 @@ fn consolidate_database(
|
||||
cache_size: None,
|
||||
compaction: config.compaction_profile.clone(),
|
||||
columns: None,
|
||||
wal: true,
|
||||
};
|
||||
|
||||
let old_path_str = try!(old_db_path.to_str().ok_or(Error::MigrationImpossible));
|
||||
|
@ -67,6 +67,7 @@ pub struct RunCmd {
|
||||
pub mode: Mode,
|
||||
pub tracing: Switch,
|
||||
pub compaction: DatabaseCompactionProfile,
|
||||
pub wal: bool,
|
||||
pub vm_type: VMType,
|
||||
pub enable_network: bool,
|
||||
pub geth_compatibility: bool,
|
||||
@ -153,6 +154,7 @@ pub fn execute(cmd: RunCmd) -> Result<(), String> {
|
||||
cmd.tracing,
|
||||
cmd.pruning,
|
||||
cmd.compaction,
|
||||
cmd.wal,
|
||||
cmd.vm_type,
|
||||
cmd.name,
|
||||
fork_name.as_ref(),
|
||||
|
@ -93,6 +93,8 @@ pub struct DatabaseConfig {
|
||||
pub compaction: CompactionProfile,
|
||||
/// Set number of columns
|
||||
pub columns: Option<u32>,
|
||||
/// Should we keep WAL enabled?
|
||||
pub wal: bool,
|
||||
}
|
||||
|
||||
impl DatabaseConfig {
|
||||
@ -111,6 +113,7 @@ impl Default for DatabaseConfig {
|
||||
max_open_files: 1024,
|
||||
compaction: CompactionProfile::default(),
|
||||
columns: None,
|
||||
wal: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -167,7 +170,9 @@ impl Database {
|
||||
}
|
||||
|
||||
let mut write_opts = WriteOptions::new();
|
||||
write_opts.disable_wal(true); // TODO: make sure this is safe
|
||||
if !config.wal {
|
||||
write_opts.disable_wal(true);
|
||||
}
|
||||
|
||||
let mut cfs: Vec<Column> = Vec::new();
|
||||
let db = match config.columns {
|
||||
|
@ -213,6 +213,7 @@ impl Manager {
|
||||
cache_size: None,
|
||||
compaction: config.compaction_profile,
|
||||
columns: columns,
|
||||
wal: true,
|
||||
};
|
||||
|
||||
let db_root = database_path(old_path);
|
||||
|
Loading…
Reference in New Issue
Block a user