Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Disable WAL #1765

Merged
merged 4 commits into from
Jul 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
2 changes: 2 additions & 0 deletions ethcore/src/client/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions parity/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions parity/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions parity/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -129,6 +130,7 @@ impl Configuration {
format: None,
pruning: pruning,
compaction: compaction,
wal: wal,
mode: mode,
tracing: tracing,
vm_type: vm_type,
Expand All @@ -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)),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -610,6 +614,7 @@ mod tests {
format: None,
pruning: Default::default(),
compaction: Default::default(),
wal: true,
mode: Default::default(),
tracing: Default::default(),
vm_type: VMType::Interpreter,
Expand All @@ -629,6 +634,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),
Expand Down Expand Up @@ -666,6 +672,7 @@ mod tests {
mode: Default::default(),
tracing: Default::default(),
compaction: Default::default(),
wal: true,
vm_type: Default::default(),
enable_network: true,
geth_compatibility: false,
Expand Down
2 changes: 2 additions & 0 deletions parity/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions parity/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 2 additions & 0 deletions parity/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,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,
Expand Down Expand Up @@ -152,6 +153,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(),
Expand Down
7 changes: 6 additions & 1 deletion util/src/kvdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -111,6 +113,7 @@ impl Default for DatabaseConfig {
max_open_files: 1024,
compaction: CompactionProfile::default(),
columns: None,
wal: true,
}
}
}
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions util/src/migration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ impl Manager {
cache_size: None,
compaction: config.compaction_profile,
columns: columns,
wal: true,
};

let db_root = database_path(old_path);
Expand Down