Skip to content

Commit

Permalink
make rocksdb_recovery_mode a u8, document it
Browse files Browse the repository at this point in the history
Signed-off-by: strawberry <[email protected]>
  • Loading branch information
girlbossceo committed Mar 23, 2024
1 parent d94319e commit 5c93df6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
29 changes: 28 additions & 1 deletion conduwuit-example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
#
Expand Down
6 changes: 3 additions & 3 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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() }

Expand Down
2 changes: 1 addition & 1 deletion src/database/abstraction/rocksdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5c93df6

Please sign in to comment.