From d8f4baf9a3d7eb29d6dcdd1b1fb6c6d79eafc728 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Sat, 4 Jun 2022 23:50:10 +0100 Subject: [PATCH] Fix the database storage size limit --- quickpeep_raker/src/storage.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/quickpeep_raker/src/storage.rs b/quickpeep_raker/src/storage.rs index d7fe180..b3dc2c3 100644 --- a/quickpeep_raker/src/storage.rs +++ b/quickpeep_raker/src/storage.rs @@ -7,7 +7,7 @@ use crate::storage::records::{ }; use anyhow::{anyhow, bail, ensure, Context}; use libmdbx::{ - Database, DatabaseFlags, Environment, EnvironmentFlags, Transaction, TransactionKind, + Database, DatabaseFlags, Environment, EnvironmentFlags, Geometry, Transaction, TransactionKind, WriteFlags, WriteMap, RO, RW, }; use log::info; @@ -106,7 +106,19 @@ impl RakerStore { let mut flags = EnvironmentFlags::default(); 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() + .set_geometry(geom) .set_max_dbs(256) .set_flags(flags) .open(path)?;