aboutsummaryrefslogtreecommitdiff
path: root/src/model/garage.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-09-11 18:03:20 +0200
committerAlex Auvolat <alex@adnab.me>2023-09-11 18:03:44 +0200
commit51b9731a086b4e158cbfa2127bcbfd6cb6274578 (patch)
treece5bac4a3fa0ef4a7546c91ad87a5161c3367a35 /src/model/garage.rs
parent5f86b48f9766019c6c74d14c2fba8c1176423cfb (diff)
downloadgarage-51b9731a086b4e158cbfa2127bcbfd6cb6274578.tar.gz
garage-51b9731a086b4e158cbfa2127bcbfd6cb6274578.zip
make lmdb's map_size configurable (fix #628)
Diffstat (limited to 'src/model/garage.rs')
-rw-r--r--src/model/garage.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/model/garage.rs b/src/model/garage.rs
index 3daa1b33..8fea6a2c 100644
--- a/src/model/garage.rs
+++ b/src/model/garage.rs
@@ -121,11 +121,22 @@ impl Garage {
// ---- LMDB DB ----
#[cfg(feature = "lmdb")]
"lmdb" | "heed" => {
+ use std::convert::TryInto;
db_path.push("db.lmdb");
info!("Opening LMDB database at: {}", db_path.display());
std::fs::create_dir_all(&db_path)
.ok_or_message("Unable to create LMDB data directory")?;
- let map_size = garage_db::lmdb_adapter::recommended_map_size();
+ let map_size = match &config.lmdb_map_size {
+ None => garage_db::lmdb_adapter::recommended_map_size(),
+ Some(v) => {
+ let v: usize = v
+ .parse::<bytesize::ByteSize>()
+ .ok()
+ .and_then(|x| x.as_u64().try_into().ok())
+ .ok_or_message("invalid value for `lmdb_map_size`")?;
+ v - (v % 4096)
+ }
+ };
use db::lmdb_adapter::heed;
let mut env_builder = heed::EnvOpenOptions::new();
@@ -142,6 +153,7 @@ impl Garage {
"OutOfMemory error while trying to open LMDB database. This can happen \
if your operating system is not allowing you to use sufficient virtual \
memory address space. Please check that no limit is set (ulimit -v). \
+ You may also try to set a smaller `lmdb_map_size` configuration parameter. \
On 32-bit machines, you should probably switch to another database engine.".into()))
}
x => x.ok_or_message("Unable to open LMDB DB")?,