Fix the database storage size limit
Some checks are pending
ci/woodpecker/push/manual Pipeline is pending
ci/woodpecker/push/check Pipeline was successful
ci/woodpecker/push/release Pipeline was successful

This commit is contained in:
Olivier 'reivilibre' 2022-06-04 23:50:10 +01:00
parent d3600bfb73
commit d8f4baf9a3

View File

@ -7,7 +7,7 @@ use crate::storage::records::{
}; };
use anyhow::{anyhow, bail, ensure, Context}; use anyhow::{anyhow, bail, ensure, Context};
use libmdbx::{ use libmdbx::{
Database, DatabaseFlags, Environment, EnvironmentFlags, Transaction, TransactionKind, Database, DatabaseFlags, Environment, EnvironmentFlags, Geometry, Transaction, TransactionKind,
WriteFlags, WriteMap, RO, RW, WriteFlags, WriteMap, RO, RW,
}; };
use log::info; use log::info;
@ -106,7 +106,19 @@ impl RakerStore {
let mut flags = EnvironmentFlags::default(); let mut flags = EnvironmentFlags::default();
flags.no_sub_dir = true; flags.no_sub_dir = true;
let mut geom = Geometry::default();
// Don't stop the database growing until it hits 64 GiB.
// (The default is 1 MiB which is just not enough!)
geom.size = Some(1024 * 1024..64 * 1024 * 1024 * 1024);
// Grow 16 MiB at a time.
geom.growth_step = Some(16 * 1024 * 1024);
// Shrink 64 MiB at a time.
geom.shrink_threshold = Some(64 * 1024 * 1024);
// (Yes these numbers represent a large database).
let env = Environment::new() let env = Environment::new()
.set_geometry(geom)
.set_max_dbs(256) .set_max_dbs(256)
.set_flags(flags) .set_flags(flags)
.open(path)?; .open(path)?;