From 101cb34f9a1b94b91717af3581f35386f20d4601 Mon Sep 17 00:00:00 2001 From: strawberry Date: Sat, 23 Mar 2024 00:27:33 -0400 Subject: [PATCH] make rocksdb_recovery_mode a u8, document it Signed-off-by: strawberry --- conduwuit-example.toml | 29 ++++++++++++++++++++++++++++- src/config/mod.rs | 6 +++--- src/database/abstraction/rocksdb.rs | 2 +- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/conduwuit-example.toml b/conduwuit-example.toml index 513820b4..562cbd09 100644 --- a/conduwuit-example.toml +++ b/conduwuit-example.toml @@ -361,6 +361,33 @@ url_preview_check_root_domain = false # Defaults to false as this uses more CPU when compressing. #rocksdb_bottommost_compression = false +# RocksDB WAL recovery mode +# +# If the database becomes corrupted, an attempt at some form of recovery or at least opening it can be made +# using this config option. +# +# In this event, provided that you have searched for any backups already, it's recommended to start by using PointInTime recovery mode. If this opens your database successfully, +# you will want to immediately run the `clear-cache` database admin command and restart Conduwuit again setting this back to 1 (TolerateCorruptedTailRecords) +# If no further issues arrise, your database should be okay now. +# +# As a very last ditch effort, if PointInTime does not fix or resolve anything, you can try SkipAnyCorruptedRecord but this +# has a good chance to do more damage than before +# +# TolerateCorruptedTailRecords is the default as generally tail records may be caused by unclean shutdowns, and any data here is likely +# federation data that can be re-retrieved by other servers again. +# +# +# The options are: +# 0 = AbsoluteConsistency +# 1 = TolerateCorruptedTailRecords (default) +# 2 = PointInTime (use me if trying to recover) +# 3 = SkipAnyCorruptedRecord (you now voided your Conduwuit warranty) +# +# See https://github.com/facebook/rocksdb/wiki/WAL-Recovery-Modes for more information +# +# Defaults to 1 (TolerateCorruptedTailRecords) +#rocksdb_recovery_mode = 1 + ### Request Timeouts, Connection Timeouts, and Connection Pooling @@ -412,7 +439,7 @@ url_preview_check_root_domain = false # You most definitely want this to be high to account for extremely large room joins, slow homeservers, your own resources etc. # # Defaults to 300 seconds -#federation_timeout +#federation_timeout = 300 # Federation client/sender max idle connections per host # diff --git a/src/config/mod.rs b/src/config/mod.rs index 8ca8ee6b..5378b2d3 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -162,7 +162,7 @@ pub struct Config { #[serde(default)] pub rocksdb_bottommost_compression: bool, #[serde(default = "default_rocksdb_recovery_mode")] - pub rocksdb_recovery_mode: u32, + pub rocksdb_recovery_mode: u8, pub emergency_password: Option, @@ -454,7 +454,7 @@ impl fmt::Display for Config { &self.rocksdb_bottommost_compression.to_string(), ), #[cfg(feature = "rocksdb")] - ("RocksDB Recovery mode", &self.rocksdb_recovery_mode.to_string()), + ("RocksDB Recovery Mode", &self.rocksdb_recovery_mode.to_string()), ("Prevent Media Downloads From", { let mut lst = vec![]; for domain in &self.prevent_media_downloads_from { @@ -576,7 +576,7 @@ fn default_presence_idle_timeout_s() -> u64 { 5 * 60 } fn default_presence_offline_timeout_s() -> u64 { 30 * 60 } -fn default_rocksdb_recovery_mode() -> u32 { 1 } +fn default_rocksdb_recovery_mode() -> u8 { 1 } fn default_rocksdb_log_level() -> String { "error".to_owned() } diff --git a/src/database/abstraction/rocksdb.rs b/src/database/abstraction/rocksdb.rs index d5c8ad9f..22d6e4ee 100644 --- a/src/database/abstraction/rocksdb.rs +++ b/src/database/abstraction/rocksdb.rs @@ -116,7 +116,7 @@ fn db_options( // Misc db_opts.create_if_missing(true); - // https://github.com/facebook/rocksdb/wiki/WAL-Recovery-Modes#ktoleratecorruptedtailrecords + // Default: https://github.com/facebook/rocksdb/wiki/WAL-Recovery-Modes#ktoleratecorruptedtailrecords // // Unclean shutdowns of a Matrix homeserver are likely to be fine when // recovered in this manner as it's likely any lost information will be