Add an option to fix the pathological space usage of RocksDB on btrfs.
This commit is contained in:
@@ -1350,6 +1350,20 @@ pub struct Config {
|
||||
#[serde(default)]
|
||||
pub rocksdb_never_drop_columns: bool,
|
||||
|
||||
/// Configures RocksDB to not preallocate WAL logs.
|
||||
///
|
||||
/// Normally, RocksDB allocates certain types of files by calling
|
||||
/// fallocate, writing the file contents, then truncating the logs to the
|
||||
/// proper size. This causes pathological disk space usage on btrfs due
|
||||
/// how it interacts with its Copy-on-Write implementation.
|
||||
///
|
||||
/// It is recommended to set this to false if you run the server on btrfs,
|
||||
/// and not touch it otherwise.
|
||||
///
|
||||
/// default: true
|
||||
#[serde(default = "true_fn")]
|
||||
pub rocksdb_allow_fallocate: bool,
|
||||
|
||||
/// This is a password that can be configured that will let you login to the
|
||||
/// server bot account (currently `@conduit`) for emergency troubleshooting
|
||||
/// purposes such as recovering/recreating your admin room, or inviting
|
||||
|
||||
@@ -4,6 +4,7 @@ use rocksdb::{Cache, DBRecoveryMode, Env, LogLevel, Options, statistics::StatsLe
|
||||
use tuwunel_core::{Config, Result, utils};
|
||||
|
||||
use super::{cf_opts::cache_size_f64, logger::handle as handle_log};
|
||||
use crate::util::map_err;
|
||||
|
||||
/// Create database-wide options suitable for opening the database. This also
|
||||
/// sets our default column options in case of opening a column with the same
|
||||
@@ -57,6 +58,10 @@ pub(crate) fn db_options(config: &Config, env: &Env, row_cache: &Cache) -> Resul
|
||||
opts.set_wal_size_limit_mb(1024);
|
||||
opts.set_max_total_wal_size(1024 * 1024 * 512);
|
||||
opts.set_writable_file_max_buffer_size(1024 * 1024 * 2);
|
||||
if !config.rocksdb_allow_fallocate {
|
||||
opts.set_options_from_string("allow_fallocate=false")
|
||||
.map_err(map_err)?;
|
||||
}
|
||||
|
||||
// Misc
|
||||
opts.set_disable_auto_compactions(!config.rocksdb_compaction);
|
||||
|
||||
@@ -1142,6 +1142,18 @@
|
||||
#
|
||||
#rocksdb_never_drop_columns = false
|
||||
|
||||
# Configures RocksDB to not preallocate WAL logs.
|
||||
#
|
||||
# Normally, RocksDB allocates certain types of files by calling
|
||||
# fallocate, writing the file contents, then truncating the logs to the
|
||||
# proper size. This causes pathological disk space usage on btrfs due
|
||||
# how it interacts with its Copy-on-Write implementation.
|
||||
#
|
||||
# It is recommended to set this to false if you run the server on btrfs,
|
||||
# and not touch it otherwise.
|
||||
#
|
||||
#rocksdb_allow_fallocate = true
|
||||
|
||||
# This is a password that can be configured that will let you login to the
|
||||
# server bot account (currently `@conduit`) for emergency troubleshooting
|
||||
# purposes such as recovering/recreating your admin room, or inviting
|
||||
|
||||
Reference in New Issue
Block a user