From bade4ed17f6f2d6d93b7760f2cae796ce2b2ede0 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 6 Apr 2024 17:37:56 -0700 Subject: [PATCH] conf item to toggle periodic cleanup for rocksdb Signed-off-by: Jason Volk --- conduwuit-example.toml | 5 +++++ src/config/mod.rs | 3 +++ src/database/mod.rs | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/conduwuit-example.toml b/conduwuit-example.toml index 045d1c3b..619b01c5 100644 --- a/conduwuit-example.toml +++ b/conduwuit-example.toml @@ -441,6 +441,11 @@ url_preview_check_root_domain = false # Defaults to 1 (TolerateCorruptedTailRecords) #rocksdb_recovery_mode = 1 +# Controls whether memory buffers are written to storage at the fixed interval set by `cleanup_period_interval` +# even when they are not full. Setting this will increase load on the storage backplane and is never advised +# under normal circumstances. +#rocksdb_periodic_cleanup = false + ### Domain Name Resolution and Caching diff --git a/src/config/mod.rs b/src/config/mod.rs index c4b5fc3e..e32eafcb 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -211,6 +211,8 @@ pub struct Config { pub rocksdb_repair: bool, #[serde(default)] pub rocksdb_read_only: bool, + #[serde(default)] + pub rocksdb_periodic_cleanup: bool, pub emergency_password: Option, @@ -635,6 +637,7 @@ impl fmt::Display for Config { ("RocksDB Recovery Mode", &self.rocksdb_recovery_mode.to_string()), ("RocksDB Repair Mode", &self.rocksdb_repair.to_string()), ("RocksDB Read-only Mode", &self.rocksdb_read_only.to_string()), + ("RocksDB Periodic Cleanup", &self.rocksdb_periodic_cleanup.to_string()), ("Prevent Media Downloads From", { let mut lst = vec![]; for domain in &self.prevent_media_downloads_from { diff --git a/src/database/mod.rs b/src/database/mod.rs index 41e8d5b8..3ace1ecd 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -545,6 +545,10 @@ impl KeyValueDatabase { } fn perform_cleanup() { + if !services().globals.config.rocksdb_periodic_cleanup { + return; + } + let start = Instant::now(); if let Err(e) = services().globals.cleanup() { error!(target: "database-cleanup", "Ran into an error during cleanup: {}", e);