aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock1
-rw-r--r--Cargo.nix3
-rw-r--r--doc/book/reference-manual/configuration.md9
-rw-r--r--src/model/Cargo.toml1
-rw-r--r--src/model/garage.rs14
-rw-r--r--src/util/config.rs4
6 files changed, 30 insertions, 2 deletions
diff --git a/Cargo.lock b/Cargo.lock
index d14701cf..eab8e853 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1340,6 +1340,7 @@ dependencies = [
"async-trait",
"base64 0.21.3",
"blake2",
+ "bytesize",
"err-derive",
"futures",
"futures-util",
diff --git a/Cargo.nix b/Cargo.nix
index 9e458f88..60022209 100644
--- a/Cargo.nix
+++ b/Cargo.nix
@@ -33,7 +33,7 @@ args@{
ignoreLockHash,
}:
let
- nixifiedLockHash = "b958f9aca0ee3fb1f7b52b15508132d0a96480a7f43f83e0da6609c0fe1812ef";
+ nixifiedLockHash = "c5e95ea3fbf4a23e07fe76a8c8886e4eb4a7c95b2d9ca8fa22fa4d8792b4d29f";
workspaceSrc = if args.workspaceSrc == null then ./. else args.workspaceSrc;
currentLockHash = builtins.hashFile "sha256" (workspaceSrc + /Cargo.lock);
lockHashIgnored = if ignoreLockHash
@@ -1911,6 +1911,7 @@ in
async_trait = (buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".async-trait."0.1.73" { profileName = "__noProfile"; }).out;
base64 = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".base64."0.21.3" { inherit profileName; }).out;
blake2 = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".blake2."0.10.6" { inherit profileName; }).out;
+ bytesize = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".bytesize."1.3.0" { inherit profileName; }).out;
err_derive = (buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".err-derive."0.3.1" { profileName = "__noProfile"; }).out;
futures = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures."0.3.28" { inherit profileName; }).out;
futures_util = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures-util."0.3.28" { inherit profileName; }).out;
diff --git a/doc/book/reference-manual/configuration.md b/doc/book/reference-manual/configuration.md
index b916bb61..c3b8ca00 100644
--- a/doc/book/reference-manual/configuration.md
+++ b/doc/book/reference-manual/configuration.md
@@ -17,6 +17,7 @@ block_size = 1048576
sled_cache_capacity = 134217728
sled_flush_every_ms = 2000
+lmdb_map_size = "10T"
replication_mode = "3"
@@ -160,6 +161,14 @@ Increase this if sled is thrashing your SSD, at the risk of losing more data in
of a power outage (though this should not matter much as data is replicated on other
nodes). The default value, 2000ms, should be appropriate for most use cases.
+### `lmdb_map_size`
+
+This parameters can be used to set the map size used by LMDB,
+which is the size of the virtual memory region used for mapping the database file.
+The value of this parameter is the maximum size the metadata database can take.
+This value is not bound by the physical RAM size of the machine running Garage.
+If not specified, it defaults to 1GiB on 32-bit machines and 1TiB on 64-bit machines.
+
### `replication_mode`
Garage supports the following replication modes:
diff --git a/src/model/Cargo.toml b/src/model/Cargo.toml
index 1d3600a6..caf7d1b0 100644
--- a/src/model/Cargo.toml
+++ b/src/model/Cargo.toml
@@ -23,6 +23,7 @@ garage_util.workspace = true
async-trait = "0.1.7"
arc-swap = "1.0"
blake2 = "0.10"
+bytesize = "1.2"
err-derive = "0.3"
hex = "0.4"
base64 = "0.21"
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")?,
diff --git a/src/util/config.rs b/src/util/config.rs
index 1da95b2f..070bd83e 100644
--- a/src/util/config.rs
+++ b/src/util/config.rs
@@ -72,6 +72,10 @@ pub struct Config {
#[serde(default = "default_sled_flush_every_ms")]
pub sled_flush_every_ms: u64,
+ /// LMDB map size
+ #[serde(default)]
+ pub lmdb_map_size: Option<String>,
+
// -- APIs
/// Configuration for S3 api
pub s3_api: S3ApiConfig,