risingwave_common/config/
meta.rs

1// Copyright 2025 RisingWave Labs
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use super::*;
16
17#[derive(Copy, Clone, Debug, Default, ValueEnum, Serialize, Deserialize)]
18pub enum MetaBackend {
19    #[default]
20    Mem,
21    Sql, // any database url
22    Sqlite,
23    Postgres,
24    Mysql,
25}
26
27#[derive(Copy, Clone, Debug, Default)]
28pub enum DefaultParallelism {
29    #[default]
30    Full,
31    Default(NonZeroUsize),
32}
33
34impl Serialize for DefaultParallelism {
35    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
36    where
37        S: Serializer,
38    {
39        #[derive(Debug, Serialize, Deserialize)]
40        #[serde(untagged)]
41        enum Parallelism {
42            Str(String),
43            Int(usize),
44        }
45        match self {
46            DefaultParallelism::Full => Parallelism::Str("Full".to_owned()).serialize(serializer),
47            DefaultParallelism::Default(val) => {
48                Parallelism::Int(val.get() as _).serialize(serializer)
49            }
50        }
51    }
52}
53
54impl<'de> Deserialize<'de> for DefaultParallelism {
55    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
56    where
57        D: serde::Deserializer<'de>,
58    {
59        #[derive(Debug, Deserialize)]
60        #[serde(untagged)]
61        enum Parallelism {
62            Str(String),
63            Int(usize),
64        }
65        let p = Parallelism::deserialize(deserializer)?;
66        match p {
67            Parallelism::Str(s) => {
68                if s.trim().eq_ignore_ascii_case("full") {
69                    Ok(DefaultParallelism::Full)
70                } else {
71                    Err(serde::de::Error::custom(format!(
72                        "invalid default parallelism: {}",
73                        s
74                    )))
75                }
76            }
77            Parallelism::Int(i) => Ok(DefaultParallelism::Default(
78                // Note: we won't check whether this exceeds the maximum parallelism (i.e., vnode count)
79                // here because it requires extra context. The check will be done when scheduling jobs.
80                NonZeroUsize::new(i).ok_or_else(|| {
81                    serde::de::Error::custom("default parallelism should not be 0")
82                })?,
83            )),
84        }
85    }
86}
87
88/// The section `[meta]` in `risingwave.toml`.
89#[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde, ConfigDoc)]
90pub struct MetaConfig {
91    /// Objects within `min_sst_retention_time_sec` won't be deleted by hummock full GC, even they
92    /// are dangling.
93    #[serde(default = "default::meta::min_sst_retention_time_sec")]
94    pub min_sst_retention_time_sec: u64,
95
96    /// Interval of automatic hummock full GC.
97    #[serde(default = "default::meta::full_gc_interval_sec")]
98    pub full_gc_interval_sec: u64,
99
100    /// Max number of object per full GC job can fetch.
101    #[serde(default = "default::meta::full_gc_object_limit")]
102    pub full_gc_object_limit: u64,
103
104    /// Duration in seconds to retain garbage collection history data.
105    #[serde(default = "default::meta::gc_history_retention_time_sec")]
106    pub gc_history_retention_time_sec: u64,
107
108    /// Max number of inflight time travel query.
109    #[serde(default = "default::meta::max_inflight_time_travel_query")]
110    pub max_inflight_time_travel_query: u64,
111
112    /// Schedule compaction for all compaction groups with this interval.
113    #[serde(default = "default::meta::periodic_compaction_interval_sec")]
114    pub periodic_compaction_interval_sec: u64,
115
116    /// Interval of invoking a vacuum job, to remove stale metadata from meta store and objects
117    /// from object store.
118    #[serde(default = "default::meta::vacuum_interval_sec")]
119    pub vacuum_interval_sec: u64,
120
121    /// The spin interval inside a vacuum job. It avoids the vacuum job monopolizing resources of
122    /// meta node.
123    #[serde(default = "default::meta::vacuum_spin_interval_ms")]
124    pub vacuum_spin_interval_ms: u64,
125
126    /// Interval of hummock version checkpoint.
127    #[serde(default = "default::meta::hummock_version_checkpoint_interval_sec")]
128    pub hummock_version_checkpoint_interval_sec: u64,
129
130    /// If enabled, `SSTable` object file and version delta will be retained.
131    ///
132    /// `SSTable` object file need to be deleted via full GC.
133    ///
134    /// version delta need to be manually deleted.
135    #[serde(default = "default::meta::enable_hummock_data_archive")]
136    pub enable_hummock_data_archive: bool,
137
138    /// The interval at which a Hummock version snapshot is taken for time travel.
139    ///
140    /// Larger value indicates less storage overhead but worse query performance.
141    #[serde(default = "default::meta::hummock_time_travel_snapshot_interval")]
142    pub hummock_time_travel_snapshot_interval: u64,
143
144    /// The minimum delta log number a new checkpoint should compact, otherwise the checkpoint
145    /// attempt is rejected.
146    #[serde(default = "default::meta::min_delta_log_num_for_hummock_version_checkpoint")]
147    pub min_delta_log_num_for_hummock_version_checkpoint: u64,
148
149    /// Maximum allowed heartbeat interval in seconds.
150    #[serde(default = "default::meta::max_heartbeat_interval_sec")]
151    pub max_heartbeat_interval_secs: u32,
152
153    /// Whether to enable fail-on-recovery. Should only be used in e2e tests.
154    #[serde(default)]
155    pub disable_recovery: bool,
156
157    /// Whether to disable adaptive-scaling feature.
158    #[serde(default)]
159    pub disable_automatic_parallelism_control: bool,
160
161    /// The number of streaming jobs per scaling operation.
162    #[serde(default = "default::meta::parallelism_control_batch_size")]
163    pub parallelism_control_batch_size: usize,
164
165    /// The period of parallelism control trigger.
166    #[serde(default = "default::meta::parallelism_control_trigger_period_sec")]
167    pub parallelism_control_trigger_period_sec: u64,
168
169    /// The first delay of parallelism control.
170    #[serde(default = "default::meta::parallelism_control_trigger_first_delay_sec")]
171    pub parallelism_control_trigger_first_delay_sec: u64,
172
173    #[serde(default = "default::meta::meta_leader_lease_secs")]
174    pub meta_leader_lease_secs: u64,
175
176    /// After specified seconds of idle (no mview or flush), the process will be exited.
177    /// It is mainly useful for playgrounds.
178    #[serde(default)]
179    pub dangerous_max_idle_secs: Option<u64>,
180
181    /// The default global parallelism for all streaming jobs, if user doesn't specify the
182    /// parallelism, this value will be used. `FULL` means use all available parallelism units,
183    /// otherwise it's a number.
184    #[serde(default = "default::meta::default_parallelism")]
185    pub default_parallelism: DefaultParallelism,
186
187    /// Whether to enable deterministic compaction scheduling, which
188    /// will disable all auto scheduling of compaction tasks.
189    /// Should only be used in e2e tests.
190    #[serde(default)]
191    pub enable_compaction_deterministic: bool,
192
193    /// Enable sanity check when SSTs are committed.
194    #[serde(default)]
195    pub enable_committed_sst_sanity_check: bool,
196
197    #[serde(default = "default::meta::node_num_monitor_interval_sec")]
198    pub node_num_monitor_interval_sec: u64,
199
200    #[serde(default = "default::meta::backend")]
201    pub backend: MetaBackend,
202
203    /// Schedule `space_reclaim` compaction for all compaction groups with this interval.
204    #[serde(default = "default::meta::periodic_space_reclaim_compaction_interval_sec")]
205    pub periodic_space_reclaim_compaction_interval_sec: u64,
206
207    /// Schedule `ttl_reclaim` compaction for all compaction groups with this interval.
208    #[serde(default = "default::meta::periodic_ttl_reclaim_compaction_interval_sec")]
209    pub periodic_ttl_reclaim_compaction_interval_sec: u64,
210
211    #[serde(default = "default::meta::periodic_tombstone_reclaim_compaction_interval_sec")]
212    pub periodic_tombstone_reclaim_compaction_interval_sec: u64,
213
214    #[serde(default = "default::meta::move_table_size_limit")]
215    #[deprecated]
216    pub move_table_size_limit: u64,
217
218    #[serde(default = "default::meta::split_group_size_limit")]
219    #[deprecated]
220    pub split_group_size_limit: u64,
221
222    #[serde(default = "default::meta::cut_table_size_limit")]
223    #[deprecated]
224    pub cut_table_size_limit: u64,
225
226    /// Whether to protect dropping a table with incoming sink.
227    #[serde(default = "default::meta::protect_drop_table_with_incoming_sink")]
228    pub protect_drop_table_with_incoming_sink: bool,
229
230    #[serde(default, flatten)]
231    #[config_doc(omitted)]
232    pub unrecognized: Unrecognized<Self>,
233
234    /// Whether config object storage bucket lifecycle to purge stale data.
235    #[serde(default)]
236    pub do_not_config_object_storage_lifecycle: bool,
237
238    /// Count of partition in split group. Meta will assign this value to every new group when it splits from default-group by automatically.
239    /// Each partition contains aligned data of `vnode_count / partition_vnode_count` consecutive virtual-nodes of one state table.
240    #[serde(default = "default::meta::partition_vnode_count")]
241    pub partition_vnode_count: u32,
242
243    /// The threshold of write throughput to trigger a group split.
244    #[serde(
245        default = "default::meta::table_high_write_throughput_threshold",
246        alias = "table_write_throughput_threshold"
247    )]
248    pub table_high_write_throughput_threshold: u64,
249
250    #[serde(
251        default = "default::meta::table_low_write_throughput_threshold",
252        alias = "min_table_split_write_throughput"
253    )]
254    /// The threshold of write throughput to trigger a group merge.
255    pub table_low_write_throughput_threshold: u64,
256
257    // If the compaction task does not report heartbeat beyond the
258    // `compaction_task_max_heartbeat_interval_secs` interval, we will cancel the task
259    #[serde(default = "default::meta::compaction_task_max_heartbeat_interval_secs")]
260    pub compaction_task_max_heartbeat_interval_secs: u64,
261
262    // If the compaction task does not change in progress beyond the
263    // `compaction_task_max_heartbeat_interval_secs` interval, we will cancel the task
264    #[serde(default = "default::meta::compaction_task_max_progress_interval_secs")]
265    pub compaction_task_max_progress_interval_secs: u64,
266
267    #[serde(default)]
268    #[config_doc(nested)]
269    pub compaction_config: CompactionConfig,
270
271    /// Count of partitions of tables in default group and materialized view group.
272    /// The meta node will decide according to some strategy whether to cut the boundaries of the file according to the vnode alignment.
273    /// Each partition contains aligned data of `vnode_count / hybrid_partition_vnode_count` consecutive virtual-nodes of one state table.
274    /// Set it zero to disable this feature.
275    #[serde(default = "default::meta::hybrid_partition_vnode_count")]
276    pub hybrid_partition_vnode_count: u32,
277
278    #[serde(default = "default::meta::event_log_enabled")]
279    pub event_log_enabled: bool,
280    /// Keeps the latest N events per channel.
281    #[serde(default = "default::meta::event_log_channel_max_size")]
282    pub event_log_channel_max_size: u32,
283
284    #[serde(default, with = "meta_prefix")]
285    #[config_doc(omitted)]
286    pub developer: MetaDeveloperConfig,
287    /// Whether compactor should rewrite row to remove dropped column.
288    #[serde(default = "default::meta::enable_dropped_column_reclaim")]
289    pub enable_dropped_column_reclaim: bool,
290
291    /// Whether to split the compaction group when the size of the group exceeds the `compaction_group_config.max_estimated_group_size() * split_group_size_ratio`.
292    #[serde(default = "default::meta::split_group_size_ratio")]
293    pub split_group_size_ratio: f64,
294
295    // During group scheduling, the configured `*_throughput_ratio` is used to determine if the sample exceeds the threshold.
296    // Use `table_stat_throuput_window_seconds_for_*` to check if the split and merge conditions are met.
297    /// To split the compaction group when the high throughput statistics of the group exceeds the threshold.
298    #[serde(default = "default::meta::table_stat_high_write_throughput_ratio_for_split")]
299    pub table_stat_high_write_throughput_ratio_for_split: f64,
300
301    /// To merge the compaction group when the low throughput statistics of the group exceeds the threshold.
302    #[serde(default = "default::meta::table_stat_low_write_throughput_ratio_for_merge")]
303    pub table_stat_low_write_throughput_ratio_for_merge: f64,
304
305    // Hummock also control the size of samples to be judged during group scheduling by `table_stat_sample_size_for_split` and `table_stat_sample_size_for_merge`.
306    // Will use max(table_stat_throuput_window_seconds_for_split /ckpt, table_stat_throuput_window_seconds_for_merge/ckpt) as the global sample size.
307    // For example, if `table_stat_throuput_window_seconds_for_merge` = 240 and `table_stat_throuput_window_seconds_for_split` = 60, and `ckpt_sec = 1`,
308    //  global sample size will be max(240/1, 60/1), then only the last 60 samples will be considered for split, and so on.
309    /// The window seconds of table throughput statistic history for split compaction group.
310    #[serde(default = "default::meta::table_stat_throuput_window_seconds_for_split")]
311    pub table_stat_throuput_window_seconds_for_split: usize,
312
313    /// The window seconds of table throughput statistic history for merge compaction group.
314    #[serde(default = "default::meta::table_stat_throuput_window_seconds_for_merge")]
315    pub table_stat_throuput_window_seconds_for_merge: usize,
316
317    /// The threshold of table size in one compact task to decide whether to partition one table into `hybrid_partition_vnode_count` parts, which belongs to default group and materialized view group.
318    /// Set it max value of 64-bit number to disable this feature.
319    #[serde(default = "default::meta::compact_task_table_size_partition_threshold_low")]
320    pub compact_task_table_size_partition_threshold_low: u64,
321
322    /// The threshold of table size in one compact task to decide whether to partition one table into `partition_vnode_count` parts, which belongs to default group and materialized view group.
323    /// Set it max value of 64-bit number to disable this feature.
324    #[serde(default = "default::meta::compact_task_table_size_partition_threshold_high")]
325    pub compact_task_table_size_partition_threshold_high: u64,
326
327    /// The interval of the periodic scheduling compaction group split job.
328    #[serde(
329        default = "default::meta::periodic_scheduling_compaction_group_split_interval_sec",
330        alias = "periodic_split_compact_group_interval_sec"
331    )]
332    pub periodic_scheduling_compaction_group_split_interval_sec: u64,
333
334    /// The interval of the periodic scheduling compaction group merge job.
335    #[serde(default = "default::meta::periodic_scheduling_compaction_group_merge_interval_sec")]
336    pub periodic_scheduling_compaction_group_merge_interval_sec: u64,
337
338    /// The threshold of each dimension of the compaction group after merging. When the dimension * `compaction_group_merge_dimension_threshold` >= limit, the merging job will be rejected.
339    #[serde(default = "default::meta::compaction_group_merge_dimension_threshold")]
340    pub compaction_group_merge_dimension_threshold: f64,
341
342    /// The interval that the CDC table splits initialization should yield to avoid overloading upstream system.
343    #[serde(default = "default::meta::cdc_table_split_init_sleep_interval_splits")]
344    pub cdc_table_split_init_sleep_interval_splits: u64,
345
346    /// The duration that the CDC table splits initialization should yield to avoid overloading upstream system.
347    #[serde(default = "default::meta::cdc_table_split_init_sleep_duration_millis")]
348    pub cdc_table_split_init_sleep_duration_millis: u64,
349
350    /// The batch size that the CDC table splits initialization should use when persisting to meta store.
351    #[serde(default = "default::meta::cdc_table_split_init_insert_batch_size")]
352    pub cdc_table_split_init_insert_batch_size: u64,
353
354    #[serde(default)]
355    #[config_doc(nested)]
356    pub meta_store_config: MetaStoreConfig,
357}
358
359serde_with::with_prefix!(meta_prefix "meta_");
360
361/// Note: only applies to meta store backends other than `SQLite`.
362#[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde, ConfigDoc)]
363pub struct MetaStoreConfig {
364    /// Maximum number of connections for the meta store connection pool.
365    #[serde(default = "default::meta_store_config::max_connections")]
366    pub max_connections: u32,
367    /// Minimum number of connections for the meta store connection pool.
368    #[serde(default = "default::meta_store_config::min_connections")]
369    pub min_connections: u32,
370    /// Connection timeout in seconds for a meta store connection.
371    #[serde(default = "default::meta_store_config::connection_timeout_sec")]
372    pub connection_timeout_sec: u64,
373    /// Idle timeout in seconds for a meta store connection.
374    #[serde(default = "default::meta_store_config::idle_timeout_sec")]
375    pub idle_timeout_sec: u64,
376    /// Acquire timeout in seconds for a meta store connection.
377    #[serde(default = "default::meta_store_config::acquire_timeout_sec")]
378    pub acquire_timeout_sec: u64,
379}
380
381/// The subsections `[meta.developer]`.
382///
383/// It is put at [`MetaConfig::developer`].
384#[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde, ConfigDoc)]
385pub struct MetaDeveloperConfig {
386    /// The number of traces to be cached in-memory by the tracing collector
387    /// embedded in the meta node.
388    #[serde(default = "default::developer::meta_cached_traces_num")]
389    pub cached_traces_num: u32,
390
391    /// The maximum memory usage in bytes for the tracing collector embedded
392    /// in the meta node.
393    #[serde(default = "default::developer::meta_cached_traces_memory_limit_bytes")]
394    pub cached_traces_memory_limit_bytes: usize,
395
396    /// Compaction picker config
397    #[serde(default = "default::developer::enable_trivial_move")]
398    pub enable_trivial_move: bool,
399    #[serde(default = "default::developer::enable_check_task_level_overlap")]
400    pub enable_check_task_level_overlap: bool,
401    #[serde(default = "default::developer::max_trivial_move_task_count_per_loop")]
402    pub max_trivial_move_task_count_per_loop: usize,
403
404    #[serde(default = "default::developer::max_get_task_probe_times")]
405    pub max_get_task_probe_times: usize,
406
407    /// Max number of actor allowed per parallelism (default = 100).
408    /// CREATE MV/Table will be noticed when the number of actors exceeds this limit.
409    #[serde(default = "default::developer::actor_cnt_per_worker_parallelism_soft_limit")]
410    pub actor_cnt_per_worker_parallelism_soft_limit: usize,
411
412    /// Max number of actor allowed per parallelism (default = 400).
413    /// CREATE MV/Table will be rejected when the number of actors exceeds this limit.
414    #[serde(default = "default::developer::actor_cnt_per_worker_parallelism_hard_limit")]
415    pub actor_cnt_per_worker_parallelism_hard_limit: usize,
416
417    /// Max number of SSTs fetched from meta store per SELECT, during time travel Hummock version replay.
418    #[serde(default = "default::developer::hummock_time_travel_sst_info_fetch_batch_size")]
419    pub hummock_time_travel_sst_info_fetch_batch_size: usize,
420
421    /// Max number of SSTs inserted into meta store per INSERT, during time travel metadata writing.
422    #[serde(default = "default::developer::hummock_time_travel_sst_info_insert_batch_size")]
423    pub hummock_time_travel_sst_info_insert_batch_size: usize,
424
425    #[serde(default = "default::developer::time_travel_vacuum_interval_sec")]
426    pub time_travel_vacuum_interval_sec: u64,
427
428    /// Max number of epoch-to-version inserted into meta store per INSERT, during time travel metadata writing.
429    #[serde(default = "default::developer::hummock_time_travel_epoch_version_insert_batch_size")]
430    pub hummock_time_travel_epoch_version_insert_batch_size: usize,
431
432    #[serde(default = "default::developer::hummock_gc_history_insert_batch_size")]
433    pub hummock_gc_history_insert_batch_size: usize,
434
435    #[serde(default = "default::developer::hummock_time_travel_filter_out_objects_batch_size")]
436    pub hummock_time_travel_filter_out_objects_batch_size: usize,
437
438    #[serde(default = "default::developer::hummock_time_travel_filter_out_objects_v1")]
439    pub hummock_time_travel_filter_out_objects_v1: bool,
440
441    #[serde(
442        default = "default::developer::hummock_time_travel_filter_out_objects_list_version_batch_size"
443    )]
444    pub hummock_time_travel_filter_out_objects_list_version_batch_size: usize,
445
446    #[serde(
447        default = "default::developer::hummock_time_travel_filter_out_objects_list_delta_batch_size"
448    )]
449    pub hummock_time_travel_filter_out_objects_list_delta_batch_size: usize,
450
451    #[serde(default)]
452    pub compute_client_config: RpcClientConfig,
453
454    #[serde(default)]
455    pub stream_client_config: RpcClientConfig,
456
457    #[serde(default)]
458    pub frontend_client_config: RpcClientConfig,
459}
460
461#[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde, ConfigDoc)]
462pub struct CompactionConfig {
463    #[serde(default = "default::compaction_config::max_bytes_for_level_base")]
464    pub max_bytes_for_level_base: u64,
465    #[serde(default = "default::compaction_config::max_bytes_for_level_multiplier")]
466    pub max_bytes_for_level_multiplier: u64,
467    #[serde(default = "default::compaction_config::max_compaction_bytes")]
468    pub max_compaction_bytes: u64,
469    #[serde(default = "default::compaction_config::sub_level_max_compaction_bytes")]
470    pub sub_level_max_compaction_bytes: u64,
471    #[serde(default = "default::compaction_config::level0_tier_compact_file_number")]
472    pub level0_tier_compact_file_number: u64,
473    #[serde(default = "default::compaction_config::target_file_size_base")]
474    pub target_file_size_base: u64,
475    #[serde(default = "default::compaction_config::compaction_filter_mask")]
476    pub compaction_filter_mask: u32,
477    #[serde(default = "default::compaction_config::max_sub_compaction")]
478    pub max_sub_compaction: u32,
479    #[serde(default = "default::compaction_config::level0_stop_write_threshold_sub_level_number")]
480    pub level0_stop_write_threshold_sub_level_number: u64,
481    #[serde(default = "default::compaction_config::level0_sub_level_compact_level_count")]
482    pub level0_sub_level_compact_level_count: u32,
483    #[serde(
484        default = "default::compaction_config::level0_overlapping_sub_level_compact_level_count"
485    )]
486    pub level0_overlapping_sub_level_compact_level_count: u32,
487    #[serde(default = "default::compaction_config::max_space_reclaim_bytes")]
488    pub max_space_reclaim_bytes: u64,
489    #[serde(default = "default::compaction_config::level0_max_compact_file_number")]
490    pub level0_max_compact_file_number: u64,
491    #[serde(default = "default::compaction_config::tombstone_reclaim_ratio")]
492    pub tombstone_reclaim_ratio: u32,
493    #[serde(default = "default::compaction_config::enable_emergency_picker")]
494    pub enable_emergency_picker: bool,
495    #[serde(default = "default::compaction_config::max_level")]
496    pub max_level: u32,
497    #[serde(default = "default::compaction_config::sst_allowed_trivial_move_min_size")]
498    pub sst_allowed_trivial_move_min_size: u64,
499    #[serde(default = "default::compaction_config::sst_allowed_trivial_move_max_count")]
500    pub sst_allowed_trivial_move_max_count: u32,
501    #[serde(default = "default::compaction_config::max_l0_compact_level_count")]
502    pub max_l0_compact_level_count: u32,
503    #[serde(default = "default::compaction_config::disable_auto_group_scheduling")]
504    pub disable_auto_group_scheduling: bool,
505    #[serde(default = "default::compaction_config::max_overlapping_level_size")]
506    pub max_overlapping_level_size: u64,
507    #[serde(default = "default::compaction_config::emergency_level0_sst_file_count")]
508    pub emergency_level0_sst_file_count: u32,
509    #[serde(default = "default::compaction_config::emergency_level0_sub_level_partition")]
510    pub emergency_level0_sub_level_partition: u32,
511    #[serde(default = "default::compaction_config::level0_stop_write_threshold_max_sst_count")]
512    pub level0_stop_write_threshold_max_sst_count: u32,
513    #[serde(default = "default::compaction_config::level0_stop_write_threshold_max_size")]
514    pub level0_stop_write_threshold_max_size: u64,
515    #[serde(default = "default::compaction_config::enable_optimize_l0_interval_selection")]
516    pub enable_optimize_l0_interval_selection: bool,
517}
518
519pub mod default {
520    pub use crate::config::default::developer;
521
522    pub mod meta {
523        use crate::config::{DefaultParallelism, MetaBackend};
524
525        pub fn min_sst_retention_time_sec() -> u64 {
526            3600 * 6
527        }
528
529        pub fn gc_history_retention_time_sec() -> u64 {
530            3600 * 6
531        }
532
533        pub fn full_gc_interval_sec() -> u64 {
534            3600
535        }
536
537        pub fn full_gc_object_limit() -> u64 {
538            100_000
539        }
540
541        pub fn max_inflight_time_travel_query() -> u64 {
542            1000
543        }
544
545        pub fn periodic_compaction_interval_sec() -> u64 {
546            60
547        }
548
549        pub fn vacuum_interval_sec() -> u64 {
550            30
551        }
552
553        pub fn vacuum_spin_interval_ms() -> u64 {
554            100
555        }
556
557        pub fn hummock_version_checkpoint_interval_sec() -> u64 {
558            30
559        }
560
561        pub fn enable_hummock_data_archive() -> bool {
562            false
563        }
564
565        pub fn hummock_time_travel_snapshot_interval() -> u64 {
566            100
567        }
568
569        pub fn min_delta_log_num_for_hummock_version_checkpoint() -> u64 {
570            10
571        }
572
573        pub fn max_heartbeat_interval_sec() -> u32 {
574            60
575        }
576
577        pub fn meta_leader_lease_secs() -> u64 {
578            30
579        }
580
581        pub fn default_parallelism() -> DefaultParallelism {
582            DefaultParallelism::Full
583        }
584
585        pub fn node_num_monitor_interval_sec() -> u64 {
586            10
587        }
588
589        pub fn backend() -> MetaBackend {
590            MetaBackend::Mem
591        }
592
593        pub fn periodic_space_reclaim_compaction_interval_sec() -> u64 {
594            3600 // 60min
595        }
596
597        pub fn periodic_ttl_reclaim_compaction_interval_sec() -> u64 {
598            1800 // 30mi
599        }
600
601        pub fn periodic_scheduling_compaction_group_split_interval_sec() -> u64 {
602            10 // 10s
603        }
604
605        pub fn periodic_tombstone_reclaim_compaction_interval_sec() -> u64 {
606            600
607        }
608
609        // limit the size of state table to trigger split by high throughput
610        pub fn move_table_size_limit() -> u64 {
611            10 * 1024 * 1024 * 1024 // 10GB
612        }
613
614        // limit the size of group to trigger split by group_size and avoid too many small groups
615        pub fn split_group_size_limit() -> u64 {
616            64 * 1024 * 1024 * 1024 // 64GB
617        }
618
619        pub fn protect_drop_table_with_incoming_sink() -> bool {
620            false
621        }
622
623        pub fn partition_vnode_count() -> u32 {
624            16
625        }
626
627        pub fn table_high_write_throughput_threshold() -> u64 {
628            16 * 1024 * 1024 // 16MB
629        }
630
631        pub fn table_low_write_throughput_threshold() -> u64 {
632            4 * 1024 * 1024 // 4MB
633        }
634
635        pub fn compaction_task_max_heartbeat_interval_secs() -> u64 {
636            30 // 30s
637        }
638
639        pub fn compaction_task_max_progress_interval_secs() -> u64 {
640            60 * 10 // 10min
641        }
642
643        pub fn cut_table_size_limit() -> u64 {
644            1024 * 1024 * 1024 // 1GB
645        }
646
647        pub fn hybrid_partition_vnode_count() -> u32 {
648            4
649        }
650
651        pub fn compact_task_table_size_partition_threshold_low() -> u64 {
652            128 * 1024 * 1024 // 128MB
653        }
654
655        pub fn compact_task_table_size_partition_threshold_high() -> u64 {
656            512 * 1024 * 1024 // 512MB
657        }
658
659        pub fn event_log_enabled() -> bool {
660            true
661        }
662
663        pub fn event_log_channel_max_size() -> u32 {
664            10
665        }
666
667        pub fn parallelism_control_batch_size() -> usize {
668            10
669        }
670
671        pub fn parallelism_control_trigger_period_sec() -> u64 {
672            10
673        }
674
675        pub fn parallelism_control_trigger_first_delay_sec() -> u64 {
676            30
677        }
678
679        pub fn enable_dropped_column_reclaim() -> bool {
680            false
681        }
682
683        pub fn split_group_size_ratio() -> f64 {
684            0.9
685        }
686
687        pub fn table_stat_high_write_throughput_ratio_for_split() -> f64 {
688            0.5
689        }
690
691        pub fn table_stat_low_write_throughput_ratio_for_merge() -> f64 {
692            0.7
693        }
694
695        pub fn table_stat_throuput_window_seconds_for_split() -> usize {
696            60
697        }
698
699        pub fn table_stat_throuput_window_seconds_for_merge() -> usize {
700            240
701        }
702
703        pub fn periodic_scheduling_compaction_group_merge_interval_sec() -> u64 {
704            60 * 10 // 10min
705        }
706
707        pub fn compaction_group_merge_dimension_threshold() -> f64 {
708            1.2
709        }
710
711        pub fn cdc_table_split_init_sleep_interval_splits() -> u64 {
712            1000
713        }
714
715        pub fn cdc_table_split_init_sleep_duration_millis() -> u64 {
716            500
717        }
718
719        pub fn cdc_table_split_init_insert_batch_size() -> u64 {
720            100
721        }
722    }
723
724    pub mod meta_store_config {
725        const DEFAULT_MAX_CONNECTIONS: u32 = 10;
726        const DEFAULT_MIN_CONNECTIONS: u32 = 1;
727        const DEFAULT_CONNECTION_TIMEOUT_SEC: u64 = 10;
728        const DEFAULT_IDLE_TIMEOUT_SEC: u64 = 30;
729        const DEFAULT_ACQUIRE_TIMEOUT_SEC: u64 = 30;
730
731        pub fn max_connections() -> u32 {
732            DEFAULT_MAX_CONNECTIONS
733        }
734
735        pub fn min_connections() -> u32 {
736            DEFAULT_MIN_CONNECTIONS
737        }
738
739        pub fn connection_timeout_sec() -> u64 {
740            DEFAULT_CONNECTION_TIMEOUT_SEC
741        }
742
743        pub fn idle_timeout_sec() -> u64 {
744            DEFAULT_IDLE_TIMEOUT_SEC
745        }
746
747        pub fn acquire_timeout_sec() -> u64 {
748            DEFAULT_ACQUIRE_TIMEOUT_SEC
749        }
750    }
751
752    pub mod compaction_config {
753        const MB: u64 = 1024 * 1024;
754        const GB: u64 = 1024 * 1024 * 1024;
755        const DEFAULT_MAX_COMPACTION_BYTES: u64 = 2 * GB; // 2GB
756        const DEFAULT_MIN_COMPACTION_BYTES: u64 = 128 * MB; // 128MB
757        const DEFAULT_MAX_BYTES_FOR_LEVEL_BASE: u64 = 512 * MB; // 512MB
758
759        // decrease this configure when the generation of checkpoint barrier is not frequent.
760        const DEFAULT_TIER_COMPACT_TRIGGER_NUMBER: u64 = 12;
761        const DEFAULT_TARGET_FILE_SIZE_BASE: u64 = 32 * MB;
762        // 32MB
763        const DEFAULT_MAX_SUB_COMPACTION: u32 = 4;
764        const DEFAULT_LEVEL_MULTIPLIER: u64 = 5;
765        const DEFAULT_MAX_SPACE_RECLAIM_BYTES: u64 = 512 * MB; // 512MB;
766        const DEFAULT_LEVEL0_STOP_WRITE_THRESHOLD_SUB_LEVEL_NUMBER: u64 = 300;
767        const DEFAULT_MAX_COMPACTION_FILE_COUNT: u64 = 100;
768        const DEFAULT_MIN_SUB_LEVEL_COMPACT_LEVEL_COUNT: u32 = 3;
769        const DEFAULT_MIN_OVERLAPPING_SUB_LEVEL_COMPACT_LEVEL_COUNT: u32 = 12;
770        const DEFAULT_TOMBSTONE_RATIO_PERCENT: u32 = 40;
771        const DEFAULT_EMERGENCY_PICKER: bool = true;
772        const DEFAULT_MAX_LEVEL: u32 = 6;
773        const DEFAULT_MAX_L0_COMPACT_LEVEL_COUNT: u32 = 42;
774        const DEFAULT_SST_ALLOWED_TRIVIAL_MOVE_MIN_SIZE: u64 = 4 * MB;
775        const DEFAULT_SST_ALLOWED_TRIVIAL_MOVE_MAX_COUNT: u32 = 64;
776        const DEFAULT_EMERGENCY_LEVEL0_SST_FILE_COUNT: u32 = 2000; // > 50G / 32M = 1600
777        const DEFAULT_EMERGENCY_LEVEL0_SUB_LEVEL_PARTITION: u32 = 256;
778        const DEFAULT_LEVEL0_STOP_WRITE_THRESHOLD_MAX_SST_COUNT: u32 = 10000; // 10000 * 32M = 320G
779        const DEFAULT_LEVEL0_STOP_WRITE_THRESHOLD_MAX_SIZE: u64 = 300 * 1024 * MB; // 300GB
780
781        use crate::catalog::hummock::CompactionFilterFlag;
782
783        pub fn max_bytes_for_level_base() -> u64 {
784            DEFAULT_MAX_BYTES_FOR_LEVEL_BASE
785        }
786
787        pub fn max_bytes_for_level_multiplier() -> u64 {
788            DEFAULT_LEVEL_MULTIPLIER
789        }
790
791        pub fn max_compaction_bytes() -> u64 {
792            DEFAULT_MAX_COMPACTION_BYTES
793        }
794
795        pub fn sub_level_max_compaction_bytes() -> u64 {
796            DEFAULT_MIN_COMPACTION_BYTES
797        }
798
799        pub fn level0_tier_compact_file_number() -> u64 {
800            DEFAULT_TIER_COMPACT_TRIGGER_NUMBER
801        }
802
803        pub fn target_file_size_base() -> u64 {
804            DEFAULT_TARGET_FILE_SIZE_BASE
805        }
806
807        pub fn compaction_filter_mask() -> u32 {
808            (CompactionFilterFlag::STATE_CLEAN | CompactionFilterFlag::TTL).into()
809        }
810
811        pub fn max_sub_compaction() -> u32 {
812            DEFAULT_MAX_SUB_COMPACTION
813        }
814
815        pub fn level0_stop_write_threshold_sub_level_number() -> u64 {
816            DEFAULT_LEVEL0_STOP_WRITE_THRESHOLD_SUB_LEVEL_NUMBER
817        }
818
819        pub fn level0_sub_level_compact_level_count() -> u32 {
820            DEFAULT_MIN_SUB_LEVEL_COMPACT_LEVEL_COUNT
821        }
822
823        pub fn level0_overlapping_sub_level_compact_level_count() -> u32 {
824            DEFAULT_MIN_OVERLAPPING_SUB_LEVEL_COMPACT_LEVEL_COUNT
825        }
826
827        pub fn max_space_reclaim_bytes() -> u64 {
828            DEFAULT_MAX_SPACE_RECLAIM_BYTES
829        }
830
831        pub fn level0_max_compact_file_number() -> u64 {
832            DEFAULT_MAX_COMPACTION_FILE_COUNT
833        }
834
835        pub fn tombstone_reclaim_ratio() -> u32 {
836            DEFAULT_TOMBSTONE_RATIO_PERCENT
837        }
838
839        pub fn enable_emergency_picker() -> bool {
840            DEFAULT_EMERGENCY_PICKER
841        }
842
843        pub fn max_level() -> u32 {
844            DEFAULT_MAX_LEVEL
845        }
846
847        pub fn max_l0_compact_level_count() -> u32 {
848            DEFAULT_MAX_L0_COMPACT_LEVEL_COUNT
849        }
850
851        pub fn sst_allowed_trivial_move_min_size() -> u64 {
852            DEFAULT_SST_ALLOWED_TRIVIAL_MOVE_MIN_SIZE
853        }
854
855        pub fn disable_auto_group_scheduling() -> bool {
856            false
857        }
858
859        pub fn max_overlapping_level_size() -> u64 {
860            256 * MB
861        }
862
863        pub fn sst_allowed_trivial_move_max_count() -> u32 {
864            DEFAULT_SST_ALLOWED_TRIVIAL_MOVE_MAX_COUNT
865        }
866
867        pub fn emergency_level0_sst_file_count() -> u32 {
868            DEFAULT_EMERGENCY_LEVEL0_SST_FILE_COUNT
869        }
870
871        pub fn emergency_level0_sub_level_partition() -> u32 {
872            DEFAULT_EMERGENCY_LEVEL0_SUB_LEVEL_PARTITION
873        }
874
875        pub fn level0_stop_write_threshold_max_sst_count() -> u32 {
876            DEFAULT_LEVEL0_STOP_WRITE_THRESHOLD_MAX_SST_COUNT
877        }
878
879        pub fn level0_stop_write_threshold_max_size() -> u64 {
880            DEFAULT_LEVEL0_STOP_WRITE_THRESHOLD_MAX_SIZE
881        }
882
883        pub fn enable_optimize_l0_interval_selection() -> bool {
884            false
885        }
886    }
887}