mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-10 06:26:52 +00:00
make lmdb's map_size configurable (fix #628)
This commit is contained in:
@@ -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"
|
||||
|
||||
+13
-1
@@ -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")?,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user