diff options
author | Alex Auvolat <alex@adnab.me> | 2023-05-17 14:30:53 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-05-17 14:30:53 +0200 |
commit | 19639705e6242861bd43a123456793e2d8f2c69a (patch) | |
tree | 17710b95f770cdde8e6405479f8262a12bcf6a13 /src/db | |
parent | 351d734e6c035a6f22f9fe0d62a783a81a134f45 (diff) | |
download | garage-19639705e6242861bd43a123456793e2d8f2c69a.tar.gz garage-19639705e6242861bd43a123456793e2d8f2c69a.zip |
Mark sled as deprecated, make lmdb default, and improve sqlite and lmdb defaults
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/Cargo.toml | 2 | ||||
-rw-r--r-- | src/db/bin/convert.rs | 14 | ||||
-rw-r--r-- | src/db/sled_adapter.rs | 8 |
3 files changed, 18 insertions, 6 deletions
diff --git a/src/db/Cargo.toml b/src/db/Cargo.toml index e3a65857..7401c9cd 100644 --- a/src/db/Cargo.toml +++ b/src/db/Cargo.toml @@ -33,7 +33,7 @@ pretty_env_logger = { version = "0.4", optional = true } mktemp = "0.5" [features] -default = [ "sled" ] +default = [ "sled", "lmdb", "sqlite" ] bundled-libs = [ "rusqlite/bundled" ] cli = ["clap", "pretty_env_logger"] lmdb = [ "heed" ] diff --git a/src/db/bin/convert.rs b/src/db/bin/convert.rs index bbde2048..957deedf 100644 --- a/src/db/bin/convert.rs +++ b/src/db/bin/convert.rs @@ -48,6 +48,8 @@ fn open_db(path: PathBuf, engine: String) -> Result<Db> { } "sqlite" | "sqlite3" | "rusqlite" => { let db = sqlite_adapter::rusqlite::Connection::open(&path)?; + db.pragma_update(None, "journal_mode", &"WAL")?; + db.pragma_update(None, "synchronous", &"NORMAL")?; Ok(sqlite_adapter::SqliteDb::init(db)) } "lmdb" | "heed" => { @@ -57,11 +59,13 @@ fn open_db(path: PathBuf, engine: String) -> Result<Db> { let map_size = lmdb_adapter::recommended_map_size(); - let db = lmdb_adapter::heed::EnvOpenOptions::new() - .max_dbs(100) - .map_size(map_size) - .open(&path) - .unwrap(); + let mut env_builder = lmdb_adapter::heed::EnvOpenOptions::new(); + env_builder.max_dbs(100); + env_builder.map_size(map_size); + unsafe { + env_builder.flag(heed::flags::Flags::MdbNoMetaSync); + } + let db = env_builder.open(&path)?; Ok(lmdb_adapter::LmdbDb::init(db)) } e => Err(Error(format!("Invalid DB engine: {}", e).into())), diff --git a/src/db/sled_adapter.rs b/src/db/sled_adapter.rs index cf61867d..52393a95 100644 --- a/src/db/sled_adapter.rs +++ b/src/db/sled_adapter.rs @@ -38,7 +38,15 @@ pub struct SledDb { } impl SledDb { + #[deprecated( + since = "0.9.0", + note = "The Sled database is now deprecated and will be removed in Garage v1.0. Please migrate to LMDB or Sqlite as soon as possible." + )] pub fn init(db: sled::Db) -> Db { + tracing::warn!("-------------------- IMPORTANT WARNING !!! ----------------------"); + tracing::warn!("The Sled database is now deprecated and will be removed in Garage v1.0."); + tracing::warn!("Please migrate to LMDB or Sqlite as soon as possible."); + tracing::warn!("-----------------------------------------------------------------------"); let s = Self { db, trees: RwLock::new((Vec::new(), HashMap::new())), |