aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/db/Cargo.toml2
-rw-r--r--src/db/bin/convert.rs14
-rw-r--r--src/db/sled_adapter.rs8
-rw-r--r--src/garage/Cargo.toml2
-rw-r--r--src/model/Cargo.toml2
-rw-r--r--src/model/garage.rs6
-rw-r--r--src/util/config.rs2
7 files changed, 26 insertions, 10 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())),
diff --git a/src/garage/Cargo.toml b/src/garage/Cargo.toml
index 2b366ff1..7f7c3287 100644
--- a/src/garage/Cargo.toml
+++ b/src/garage/Cargo.toml
@@ -74,7 +74,7 @@ base64 = "0.21"
[features]
-default = [ "bundled-libs", "metrics", "sled", "k2v" ]
+default = [ "bundled-libs", "metrics", "sled", "lmdb", "sqlite", "k2v" ]
k2v = [ "garage_util/k2v", "garage_api/k2v" ]
diff --git a/src/model/Cargo.toml b/src/model/Cargo.toml
index 6dc954d4..c4291c32 100644
--- a/src/model/Cargo.toml
+++ b/src/model/Cargo.toml
@@ -41,7 +41,7 @@ opentelemetry = "0.17"
netapp = "0.5"
[features]
-default = [ "sled" ]
+default = [ "sled", "lmdb", "sqlite" ]
k2v = [ "garage_util/k2v" ]
lmdb = [ "garage_db/lmdb" ]
sled = [ "garage_db/sled" ]
diff --git a/src/model/garage.rs b/src/model/garage.rs
index 3daa1b33..0fbcf334 100644
--- a/src/model/garage.rs
+++ b/src/model/garage.rs
@@ -109,6 +109,11 @@ impl Garage {
db_path.push("db.sqlite");
info!("Opening Sqlite database at: {}", db_path.display());
let db = db::sqlite_adapter::rusqlite::Connection::open(db_path)
+ .and_then(|db| {
+ db.pragma_update(None, "journal_mode", &"WAL")?;
+ db.pragma_update(None, "synchronous", &"NORMAL")?;
+ Ok(db)
+ })
.ok_or_message("Unable to open sqlite DB")?;
db::sqlite_adapter::SqliteDb::init(db)
}
@@ -133,7 +138,6 @@ impl Garage {
env_builder.max_readers(500);
env_builder.map_size(map_size);
unsafe {
- env_builder.flag(heed::flags::Flags::MdbNoSync);
env_builder.flag(heed::flags::Flags::MdbNoMetaSync);
}
let db = match env_builder.open(&db_path) {
diff --git a/src/util/config.rs b/src/util/config.rs
index 2176353e..77952356 100644
--- a/src/util/config.rs
+++ b/src/util/config.rs
@@ -164,7 +164,7 @@ pub struct KubernetesDiscoveryConfig {
}
fn default_db_engine() -> String {
- "sled".into()
+ "lmdb".into()
}
fn default_sled_cache_capacity() -> u64 {