forked from Deuxfleurs/garage
Fix garage_db build on 32-bit systems
This commit is contained in:
parent
b44d3fc796
commit
138e13071b
3 changed files with 16 additions and 14 deletions
src
|
@ -55,14 +55,7 @@ fn open_db(path: PathBuf, engine: String) -> Result<Db> {
|
||||||
Error(format!("Unable to create LMDB data directory: {}", e).into())
|
Error(format!("Unable to create LMDB data directory: {}", e).into())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let map_size = if u32::MAX as usize == usize::MAX {
|
let map_size = lmdb_adapter::recommended_map_size();
|
||||||
eprintln!(
|
|
||||||
"LMDB is not recommended on 32-bit systems, database size will be limited"
|
|
||||||
);
|
|
||||||
1usize << 30 // 1GB for 32-bit systems
|
|
||||||
} else {
|
|
||||||
1usize << 40 // 1TB for 64-bit systems
|
|
||||||
};
|
|
||||||
|
|
||||||
let db = lmdb_adapter::heed::EnvOpenOptions::new()
|
let db = lmdb_adapter::heed::EnvOpenOptions::new()
|
||||||
.max_dbs(100)
|
.max_dbs(100)
|
||||||
|
|
|
@ -327,3 +327,17 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----
|
||||||
|
|
||||||
|
#[cfg(target_pointer_width = "64")]
|
||||||
|
pub fn recommended_map_size() -> usize {
|
||||||
|
1usize << 40
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_pointer_width = "32")]
|
||||||
|
pub fn recommended_map_size() -> usize {
|
||||||
|
use log::warn;
|
||||||
|
warn!("LMDB is not recommended on 32-bit systems, database size will be limited");
|
||||||
|
1usize << 30
|
||||||
|
}
|
||||||
|
|
|
@ -57,12 +57,7 @@ pub async fn run_server(config_file: PathBuf) -> Result<(), Error> {
|
||||||
db_path.push("db.lmdb");
|
db_path.push("db.lmdb");
|
||||||
info!("Opening LMDB database at: {}", db_path.display());
|
info!("Opening LMDB database at: {}", db_path.display());
|
||||||
std::fs::create_dir_all(&db_path).expect("Unable to create LMDB data directory");
|
std::fs::create_dir_all(&db_path).expect("Unable to create LMDB data directory");
|
||||||
let map_size = if u32::MAX as usize == usize::MAX {
|
let map_size = garage_db::lmdb_adapter::recommended_map_size();
|
||||||
warn!("LMDB is not recommended on 32-bit systems, database size will be limited");
|
|
||||||
1usize << 30 // 1GB for 32-bit systems
|
|
||||||
} else {
|
|
||||||
1usize << 40 // 1TB for 64-bit systems
|
|
||||||
};
|
|
||||||
|
|
||||||
let db = db::lmdb_adapter::heed::EnvOpenOptions::new()
|
let db = db::lmdb_adapter::heed::EnvOpenOptions::new()
|
||||||
.max_dbs(100)
|
.max_dbs(100)
|
||||||
|
|
Loading…
Reference in a new issue