DatabaseSource::Auto (#9500)

* implement "auto" database backend in client/db, in progress, #9201

* move fn supports_ref_counting from DatabaseSource enum to Database trait to make it work correctly for all types of dbs

* update kvdb_rocksdb to 0.13 and use it's new config feature  to properly auto start existing database

* tests for auto database reopening

* introduce OpenDbError to cleanup opening database error handling and handle case when database is not enabled at the compile time

* cargo fmt strings again

* cargo fmt strings again

* rename DataSettingsSrc to fix test compilation

* fix the call to the new kvdb-rocksdb interdace in tests to fix compilation

* simplify OpenDbError and make it compile even when paritydb and rocksdb are disabled

* cargo fmt

* fix compilation without flag with-parity-db

* fix unused var compilation warning

* support different paths for rocksdb and paritydb in DatabaseSouce::Auto

* support "auto" database option in substrate cli

* enable Lz4 compression for some of the parity-db colums as per review suggestion

* applied review suggestions
This commit is contained in:
Marek Kotewicz
2021-08-09 15:22:28 +02:00
committed by GitHub
parent 4dc8db2b80
commit a2f7524138
21 changed files with 549 additions and 219 deletions
+2 -2
View File
@@ -22,7 +22,7 @@ serde_json = "1.0.41"
structopt = "0.3"
derive_more = "0.99.2"
kvdb = "0.10.0"
kvdb-rocksdb = "0.12.0"
kvdb-rocksdb = "0.14.0"
sp-trie = { version = "4.0.0-dev", path = "../../../primitives/trie" }
sp-core = { version = "4.0.0-dev", path = "../../../primitives/core" }
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
@@ -37,7 +37,7 @@ hex = "0.4.0"
rand = { version = "0.7.2", features = ["small_rng"] }
lazy_static = "1.4.0"
parity-util-mem = { version = "0.10.0", default-features = false, features = ["primitive-types"] }
parity-db = { version = "0.2.4" }
parity-db = { version = "0.3" }
sc-transaction-pool = { version = "4.0.0-dev", path = "../../../client/transaction-pool" }
sc-transaction-pool-api = { version = "4.0.0-dev", path = "../../../client/transaction-pool/api" }
futures = { version = "0.3.4", features = ["thread-pool"] }
+2 -3
View File
@@ -91,8 +91,7 @@ impl TempDatabase {
match db_type {
DatabaseType::RocksDb => {
let db_cfg = DatabaseConfig::with_columns(1);
let db = Database::open(&db_cfg, &self.0.path().to_string_lossy())
.expect("Database backend error");
let db = Database::open(&db_cfg, &self.0.path()).expect("Database backend error");
Arc::new(db)
},
DatabaseType::ParityDb => Arc::new(ParityDbWrapper({
@@ -101,7 +100,7 @@ impl TempDatabase {
column_options.ref_counted = true;
column_options.preimage = true;
column_options.uniform = true;
parity_db::Db::open(&options).expect("db open error")
parity_db::Db::open_or_create(&options).expect("db open error")
})),
}
}