From 6cc3ecbc304293d434b84ae1f29882104fcd11f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Vis=C3=A9e?= Date: Tue, 4 Feb 2025 15:05:23 +0100 Subject: [PATCH] Enable consensus compaction by default (#5903) * Enable consensus compaction by default * Also set new compaction default in code --- config/config.yaml | 6 ++++++ src/settings.rs | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index 336dcd3ce0..49995a1a7c 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -324,6 +324,12 @@ cluster: # We encourage you NOT to change this parameter unless you know what you are doing. tick_period_ms: 100 + # Compact consensus operations once we have this amount of applied + # operations. Allows peers to join quickly with a consensus snapshot without + # replaying a huge amount of operations. + # If 0 - disable compaction + compact_wal_entries: 128 + # Set to true to prevent service from sending usage statistics to the developers. # Read more: https://qdrant.tech/documentation/guides/telemetry telemetry_disabled: false diff --git a/src/settings.rs b/src/settings.rs index 4e7ce6c33a..f928706a52 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -114,8 +114,9 @@ pub struct ConsensusConfig { #[validate(range(min = 1))] #[serde(default = "default_message_timeout_tics")] pub message_timeout_ticks: u64, - #[serde(default)] - pub compact_wal_entries: u64, // compact WAL when it grows to enough applied entries + /// Compact WAL when it grows to enough applied entries + #[serde(default = "default_compact_wal_entries")] + pub compact_wal_entries: u64, } impl Default for ConsensusConfig { @@ -125,7 +126,7 @@ impl Default for ConsensusConfig { tick_period_ms: default_tick_period_ms(), bootstrap_timeout_sec: default_bootstrap_timeout_sec(), message_timeout_ticks: default_message_timeout_tics(), - compact_wal_entries: 0, + compact_wal_entries: default_compact_wal_entries(), } } } @@ -383,6 +384,10 @@ const fn default_message_timeout_tics() -> u64 { 10 } +const fn default_compact_wal_entries() -> u64 { + 128 +} + #[allow(clippy::unnecessary_wraps)] // Used as serde default const fn default_tls_cert_ttl() -> Option { // Default one hour