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    #[serde(default)]
343    #[config_doc(nested)]
344    pub meta_store_config: MetaStoreConfig,
345}
346
347serde_with::with_prefix!(meta_prefix "meta_");
348
349/// Note: only applies to meta store backends other than `SQLite`.
350#[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde, ConfigDoc)]
351pub struct MetaStoreConfig {
352    /// Maximum number of connections for the meta store connection pool.
353    #[serde(default = "default::meta_store_config::max_connections")]
354    pub max_connections: u32,
355    /// Minimum number of connections for the meta store connection pool.
356    #[serde(default = "default::meta_store_config::min_connections")]
357    pub min_connections: u32,
358    /// Connection timeout in seconds for a meta store connection.
359    #[serde(default = "default::meta_store_config::connection_timeout_sec")]
360    pub connection_timeout_sec: u64,
361    /// Idle timeout in seconds for a meta store connection.
362    #[serde(default = "default::meta_store_config::idle_timeout_sec")]
363    pub idle_timeout_sec: u64,
364    /// Acquire timeout in seconds for a meta store connection.
365    #[serde(default = "default::meta_store_config::acquire_timeout_sec")]
366    pub acquire_timeout_sec: u64,
367}
368
369/// The subsections `[meta.developer]`.
370///
371/// It is put at [`MetaConfig::developer`].
372#[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde, ConfigDoc)]
373pub struct MetaDeveloperConfig {
374    /// The number of traces to be cached in-memory by the tracing collector
375    /// embedded in the meta node.
376    #[serde(default = "default::developer::meta_cached_traces_num")]
377    pub cached_traces_num: u32,
378
379    /// The maximum memory usage in bytes for the tracing collector embedded
380    /// in the meta node.
381    #[serde(default = "default::developer::meta_cached_traces_memory_limit_bytes")]
382    pub cached_traces_memory_limit_bytes: usize,
383
384    /// Compaction picker config
385    #[serde(default = "default::developer::enable_trivial_move")]
386    pub enable_trivial_move: bool,
387    #[serde(default = "default::developer::enable_check_task_level_overlap")]
388    pub enable_check_task_level_overlap: bool,
389    #[serde(default = "default::developer::max_trivial_move_task_count_per_loop")]
390    pub max_trivial_move_task_count_per_loop: usize,
391
392    #[serde(default = "default::developer::max_get_task_probe_times")]
393    pub max_get_task_probe_times: usize,
394
395    /// Max number of actor allowed per parallelism (default = 100).
396    /// CREATE MV/Table will be noticed when the number of actors exceeds this limit.
397    #[serde(default = "default::developer::actor_cnt_per_worker_parallelism_soft_limit")]
398    pub actor_cnt_per_worker_parallelism_soft_limit: usize,
399
400    /// Max number of actor allowed per parallelism (default = 400).
401    /// CREATE MV/Table will be rejected when the number of actors exceeds this limit.
402    #[serde(default = "default::developer::actor_cnt_per_worker_parallelism_hard_limit")]
403    pub actor_cnt_per_worker_parallelism_hard_limit: usize,
404
405    /// Max number of SSTs fetched from meta store per SELECT, during time travel Hummock version replay.
406    #[serde(default = "default::developer::hummock_time_travel_sst_info_fetch_batch_size")]
407    pub hummock_time_travel_sst_info_fetch_batch_size: usize,
408
409    /// Max number of SSTs inserted into meta store per INSERT, during time travel metadata writing.
410    #[serde(default = "default::developer::hummock_time_travel_sst_info_insert_batch_size")]
411    pub hummock_time_travel_sst_info_insert_batch_size: usize,
412
413    #[serde(default = "default::developer::time_travel_vacuum_interval_sec")]
414    pub time_travel_vacuum_interval_sec: u64,
415
416    /// Max number of epoch-to-version inserted into meta store per INSERT, during time travel metadata writing.
417    #[serde(default = "default::developer::hummock_time_travel_epoch_version_insert_batch_size")]
418    pub hummock_time_travel_epoch_version_insert_batch_size: usize,
419
420    #[serde(default = "default::developer::hummock_gc_history_insert_batch_size")]
421    pub hummock_gc_history_insert_batch_size: usize,
422
423    #[serde(default = "default::developer::hummock_time_travel_filter_out_objects_batch_size")]
424    pub hummock_time_travel_filter_out_objects_batch_size: usize,
425
426    #[serde(default = "default::developer::hummock_time_travel_filter_out_objects_v1")]
427    pub hummock_time_travel_filter_out_objects_v1: bool,
428
429    #[serde(
430        default = "default::developer::hummock_time_travel_filter_out_objects_list_version_batch_size"
431    )]
432    pub hummock_time_travel_filter_out_objects_list_version_batch_size: usize,
433
434    #[serde(
435        default = "default::developer::hummock_time_travel_filter_out_objects_list_delta_batch_size"
436    )]
437    pub hummock_time_travel_filter_out_objects_list_delta_batch_size: usize,
438
439    #[serde(default)]
440    pub compute_client_config: RpcClientConfig,
441
442    #[serde(default)]
443    pub stream_client_config: RpcClientConfig,
444
445    #[serde(default)]
446    pub frontend_client_config: RpcClientConfig,
447}
448
449#[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde, ConfigDoc)]
450pub struct CompactionConfig {
451    #[serde(default = "default::compaction_config::max_bytes_for_level_base")]
452    pub max_bytes_for_level_base: u64,
453    #[serde(default = "default::compaction_config::max_bytes_for_level_multiplier")]
454    pub max_bytes_for_level_multiplier: u64,
455    #[serde(default = "default::compaction_config::max_compaction_bytes")]
456    pub max_compaction_bytes: u64,
457    #[serde(default = "default::compaction_config::sub_level_max_compaction_bytes")]
458    pub sub_level_max_compaction_bytes: u64,
459    #[serde(default = "default::compaction_config::level0_tier_compact_file_number")]
460    pub level0_tier_compact_file_number: u64,
461    #[serde(default = "default::compaction_config::target_file_size_base")]
462    pub target_file_size_base: u64,
463    #[serde(default = "default::compaction_config::compaction_filter_mask")]
464    pub compaction_filter_mask: u32,
465    #[serde(default = "default::compaction_config::max_sub_compaction")]
466    pub max_sub_compaction: u32,
467    #[serde(default = "default::compaction_config::level0_stop_write_threshold_sub_level_number")]
468    pub level0_stop_write_threshold_sub_level_number: u64,
469    #[serde(default = "default::compaction_config::level0_sub_level_compact_level_count")]
470    pub level0_sub_level_compact_level_count: u32,
471    #[serde(
472        default = "default::compaction_config::level0_overlapping_sub_level_compact_level_count"
473    )]
474    pub level0_overlapping_sub_level_compact_level_count: u32,
475    #[serde(default = "default::compaction_config::max_space_reclaim_bytes")]
476    pub max_space_reclaim_bytes: u64,
477    #[serde(default = "default::compaction_config::level0_max_compact_file_number")]
478    pub level0_max_compact_file_number: u64,
479    #[serde(default = "default::compaction_config::tombstone_reclaim_ratio")]
480    pub tombstone_reclaim_ratio: u32,
481    #[serde(default = "default::compaction_config::enable_emergency_picker")]
482    pub enable_emergency_picker: bool,
483    #[serde(default = "default::compaction_config::max_level")]
484    pub max_level: u32,
485    #[serde(default = "default::compaction_config::sst_allowed_trivial_move_min_size")]
486    pub sst_allowed_trivial_move_min_size: u64,
487    #[serde(default = "default::compaction_config::sst_allowed_trivial_move_max_count")]
488    pub sst_allowed_trivial_move_max_count: u32,
489    #[serde(default = "default::compaction_config::max_l0_compact_level_count")]
490    pub max_l0_compact_level_count: u32,
491    #[serde(default = "default::compaction_config::disable_auto_group_scheduling")]
492    pub disable_auto_group_scheduling: bool,
493    #[serde(default = "default::compaction_config::max_overlapping_level_size")]
494    pub max_overlapping_level_size: u64,
495    #[serde(default = "default::compaction_config::emergency_level0_sst_file_count")]
496    pub emergency_level0_sst_file_count: u32,
497    #[serde(default = "default::compaction_config::emergency_level0_sub_level_partition")]
498    pub emergency_level0_sub_level_partition: u32,
499    #[serde(default = "default::compaction_config::level0_stop_write_threshold_max_sst_count")]
500    pub level0_stop_write_threshold_max_sst_count: u32,
501    #[serde(default = "default::compaction_config::level0_stop_write_threshold_max_size")]
502    pub level0_stop_write_threshold_max_size: u64,
503    #[serde(default = "default::compaction_config::enable_optimize_l0_interval_selection")]
504    pub enable_optimize_l0_interval_selection: bool,
505}
506
507pub mod default {
508    pub use crate::config::default::developer;
509
510    pub mod meta {
511        use crate::config::{DefaultParallelism, MetaBackend};
512
513        pub fn min_sst_retention_time_sec() -> u64 {
514            3600 * 6
515        }
516
517        pub fn gc_history_retention_time_sec() -> u64 {
518            3600 * 6
519        }
520
521        pub fn full_gc_interval_sec() -> u64 {
522            3600
523        }
524
525        pub fn full_gc_object_limit() -> u64 {
526            100_000
527        }
528
529        pub fn max_inflight_time_travel_query() -> u64 {
530            1000
531        }
532
533        pub fn periodic_compaction_interval_sec() -> u64 {
534            60
535        }
536
537        pub fn vacuum_interval_sec() -> u64 {
538            30
539        }
540
541        pub fn vacuum_spin_interval_ms() -> u64 {
542            100
543        }
544
545        pub fn hummock_version_checkpoint_interval_sec() -> u64 {
546            30
547        }
548
549        pub fn enable_hummock_data_archive() -> bool {
550            false
551        }
552
553        pub fn hummock_time_travel_snapshot_interval() -> u64 {
554            100
555        }
556
557        pub fn min_delta_log_num_for_hummock_version_checkpoint() -> u64 {
558            10
559        }
560
561        pub fn max_heartbeat_interval_sec() -> u32 {
562            60
563        }
564
565        pub fn meta_leader_lease_secs() -> u64 {
566            30
567        }
568
569        pub fn default_parallelism() -> DefaultParallelism {
570            DefaultParallelism::Full
571        }
572
573        pub fn node_num_monitor_interval_sec() -> u64 {
574            10
575        }
576
577        pub fn backend() -> MetaBackend {
578            MetaBackend::Mem
579        }
580
581        pub fn periodic_space_reclaim_compaction_interval_sec() -> u64 {
582            3600 // 60min
583        }
584
585        pub fn periodic_ttl_reclaim_compaction_interval_sec() -> u64 {
586            1800 // 30mi
587        }
588
589        pub fn periodic_scheduling_compaction_group_split_interval_sec() -> u64 {
590            10 // 10s
591        }
592
593        pub fn periodic_tombstone_reclaim_compaction_interval_sec() -> u64 {
594            600
595        }
596
597        // limit the size of state table to trigger split by high throughput
598        pub fn move_table_size_limit() -> u64 {
599            10 * 1024 * 1024 * 1024 // 10GB
600        }
601
602        // limit the size of group to trigger split by group_size and avoid too many small groups
603        pub fn split_group_size_limit() -> u64 {
604            64 * 1024 * 1024 * 1024 // 64GB
605        }
606
607        pub fn protect_drop_table_with_incoming_sink() -> bool {
608            false
609        }
610
611        pub fn partition_vnode_count() -> u32 {
612            16
613        }
614
615        pub fn table_high_write_throughput_threshold() -> u64 {
616            16 * 1024 * 1024 // 16MB
617        }
618
619        pub fn table_low_write_throughput_threshold() -> u64 {
620            4 * 1024 * 1024 // 4MB
621        }
622
623        pub fn compaction_task_max_heartbeat_interval_secs() -> u64 {
624            30 // 30s
625        }
626
627        pub fn compaction_task_max_progress_interval_secs() -> u64 {
628            60 * 10 // 10min
629        }
630
631        pub fn cut_table_size_limit() -> u64 {
632            1024 * 1024 * 1024 // 1GB
633        }
634
635        pub fn hybrid_partition_vnode_count() -> u32 {
636            4
637        }
638
639        pub fn compact_task_table_size_partition_threshold_low() -> u64 {
640            128 * 1024 * 1024 // 128MB
641        }
642
643        pub fn compact_task_table_size_partition_threshold_high() -> u64 {
644            512 * 1024 * 1024 // 512MB
645        }
646
647        pub fn event_log_enabled() -> bool {
648            true
649        }
650
651        pub fn event_log_channel_max_size() -> u32 {
652            10
653        }
654
655        pub fn parallelism_control_batch_size() -> usize {
656            10
657        }
658
659        pub fn parallelism_control_trigger_period_sec() -> u64 {
660            10
661        }
662
663        pub fn parallelism_control_trigger_first_delay_sec() -> u64 {
664            30
665        }
666
667        pub fn enable_dropped_column_reclaim() -> bool {
668            false
669        }
670
671        pub fn split_group_size_ratio() -> f64 {
672            0.9
673        }
674
675        pub fn table_stat_high_write_throughput_ratio_for_split() -> f64 {
676            0.5
677        }
678
679        pub fn table_stat_low_write_throughput_ratio_for_merge() -> f64 {
680            0.7
681        }
682
683        pub fn table_stat_throuput_window_seconds_for_split() -> usize {
684            60
685        }
686
687        pub fn table_stat_throuput_window_seconds_for_merge() -> usize {
688            240
689        }
690
691        pub fn periodic_scheduling_compaction_group_merge_interval_sec() -> u64 {
692            60 * 10 // 10min
693        }
694
695        pub fn compaction_group_merge_dimension_threshold() -> f64 {
696            1.2
697        }
698    }
699
700    pub mod meta_store_config {
701        const DEFAULT_MAX_CONNECTIONS: u32 = 10;
702        const DEFAULT_MIN_CONNECTIONS: u32 = 1;
703        const DEFAULT_CONNECTION_TIMEOUT_SEC: u64 = 10;
704        const DEFAULT_IDLE_TIMEOUT_SEC: u64 = 30;
705        const DEFAULT_ACQUIRE_TIMEOUT_SEC: u64 = 30;
706
707        pub fn max_connections() -> u32 {
708            DEFAULT_MAX_CONNECTIONS
709        }
710
711        pub fn min_connections() -> u32 {
712            DEFAULT_MIN_CONNECTIONS
713        }
714
715        pub fn connection_timeout_sec() -> u64 {
716            DEFAULT_CONNECTION_TIMEOUT_SEC
717        }
718
719        pub fn idle_timeout_sec() -> u64 {
720            DEFAULT_IDLE_TIMEOUT_SEC
721        }
722
723        pub fn acquire_timeout_sec() -> u64 {
724            DEFAULT_ACQUIRE_TIMEOUT_SEC
725        }
726    }
727
728    pub mod compaction_config {
729        const MB: u64 = 1024 * 1024;
730        const GB: u64 = 1024 * 1024 * 1024;
731        const DEFAULT_MAX_COMPACTION_BYTES: u64 = 2 * GB; // 2GB
732        const DEFAULT_MIN_COMPACTION_BYTES: u64 = 128 * MB; // 128MB
733        const DEFAULT_MAX_BYTES_FOR_LEVEL_BASE: u64 = 512 * MB; // 512MB
734
735        // decrease this configure when the generation of checkpoint barrier is not frequent.
736        const DEFAULT_TIER_COMPACT_TRIGGER_NUMBER: u64 = 12;
737        const DEFAULT_TARGET_FILE_SIZE_BASE: u64 = 32 * MB;
738        // 32MB
739        const DEFAULT_MAX_SUB_COMPACTION: u32 = 4;
740        const DEFAULT_LEVEL_MULTIPLIER: u64 = 5;
741        const DEFAULT_MAX_SPACE_RECLAIM_BYTES: u64 = 512 * MB; // 512MB;
742        const DEFAULT_LEVEL0_STOP_WRITE_THRESHOLD_SUB_LEVEL_NUMBER: u64 = 300;
743        const DEFAULT_MAX_COMPACTION_FILE_COUNT: u64 = 100;
744        const DEFAULT_MIN_SUB_LEVEL_COMPACT_LEVEL_COUNT: u32 = 3;
745        const DEFAULT_MIN_OVERLAPPING_SUB_LEVEL_COMPACT_LEVEL_COUNT: u32 = 12;
746        const DEFAULT_TOMBSTONE_RATIO_PERCENT: u32 = 40;
747        const DEFAULT_EMERGENCY_PICKER: bool = true;
748        const DEFAULT_MAX_LEVEL: u32 = 6;
749        const DEFAULT_MAX_L0_COMPACT_LEVEL_COUNT: u32 = 42;
750        const DEFAULT_SST_ALLOWED_TRIVIAL_MOVE_MIN_SIZE: u64 = 4 * MB;
751        const DEFAULT_SST_ALLOWED_TRIVIAL_MOVE_MAX_COUNT: u32 = 64;
752        const DEFAULT_EMERGENCY_LEVEL0_SST_FILE_COUNT: u32 = 2000; // > 50G / 32M = 1600
753        const DEFAULT_EMERGENCY_LEVEL0_SUB_LEVEL_PARTITION: u32 = 256;
754        const DEFAULT_LEVEL0_STOP_WRITE_THRESHOLD_MAX_SST_COUNT: u32 = 10000; // 10000 * 32M = 320G
755        const DEFAULT_LEVEL0_STOP_WRITE_THRESHOLD_MAX_SIZE: u64 = 300 * 1024 * MB; // 300GB
756
757        use crate::catalog::hummock::CompactionFilterFlag;
758
759        pub fn max_bytes_for_level_base() -> u64 {
760            DEFAULT_MAX_BYTES_FOR_LEVEL_BASE
761        }
762
763        pub fn max_bytes_for_level_multiplier() -> u64 {
764            DEFAULT_LEVEL_MULTIPLIER
765        }
766
767        pub fn max_compaction_bytes() -> u64 {
768            DEFAULT_MAX_COMPACTION_BYTES
769        }
770
771        pub fn sub_level_max_compaction_bytes() -> u64 {
772            DEFAULT_MIN_COMPACTION_BYTES
773        }
774
775        pub fn level0_tier_compact_file_number() -> u64 {
776            DEFAULT_TIER_COMPACT_TRIGGER_NUMBER
777        }
778
779        pub fn target_file_size_base() -> u64 {
780            DEFAULT_TARGET_FILE_SIZE_BASE
781        }
782
783        pub fn compaction_filter_mask() -> u32 {
784            (CompactionFilterFlag::STATE_CLEAN | CompactionFilterFlag::TTL).into()
785        }
786
787        pub fn max_sub_compaction() -> u32 {
788            DEFAULT_MAX_SUB_COMPACTION
789        }
790
791        pub fn level0_stop_write_threshold_sub_level_number() -> u64 {
792            DEFAULT_LEVEL0_STOP_WRITE_THRESHOLD_SUB_LEVEL_NUMBER
793        }
794
795        pub fn level0_sub_level_compact_level_count() -> u32 {
796            DEFAULT_MIN_SUB_LEVEL_COMPACT_LEVEL_COUNT
797        }
798
799        pub fn level0_overlapping_sub_level_compact_level_count() -> u32 {
800            DEFAULT_MIN_OVERLAPPING_SUB_LEVEL_COMPACT_LEVEL_COUNT
801        }
802
803        pub fn max_space_reclaim_bytes() -> u64 {
804            DEFAULT_MAX_SPACE_RECLAIM_BYTES
805        }
806
807        pub fn level0_max_compact_file_number() -> u64 {
808            DEFAULT_MAX_COMPACTION_FILE_COUNT
809        }
810
811        pub fn tombstone_reclaim_ratio() -> u32 {
812            DEFAULT_TOMBSTONE_RATIO_PERCENT
813        }
814
815        pub fn enable_emergency_picker() -> bool {
816            DEFAULT_EMERGENCY_PICKER
817        }
818
819        pub fn max_level() -> u32 {
820            DEFAULT_MAX_LEVEL
821        }
822
823        pub fn max_l0_compact_level_count() -> u32 {
824            DEFAULT_MAX_L0_COMPACT_LEVEL_COUNT
825        }
826
827        pub fn sst_allowed_trivial_move_min_size() -> u64 {
828            DEFAULT_SST_ALLOWED_TRIVIAL_MOVE_MIN_SIZE
829        }
830
831        pub fn disable_auto_group_scheduling() -> bool {
832            false
833        }
834
835        pub fn max_overlapping_level_size() -> u64 {
836            256 * MB
837        }
838
839        pub fn sst_allowed_trivial_move_max_count() -> u32 {
840            DEFAULT_SST_ALLOWED_TRIVIAL_MOVE_MAX_COUNT
841        }
842
843        pub fn emergency_level0_sst_file_count() -> u32 {
844            DEFAULT_EMERGENCY_LEVEL0_SST_FILE_COUNT
845        }
846
847        pub fn emergency_level0_sub_level_partition() -> u32 {
848            DEFAULT_EMERGENCY_LEVEL0_SUB_LEVEL_PARTITION
849        }
850
851        pub fn level0_stop_write_threshold_max_sst_count() -> u32 {
852            DEFAULT_LEVEL0_STOP_WRITE_THRESHOLD_MAX_SST_COUNT
853        }
854
855        pub fn level0_stop_write_threshold_max_size() -> u64 {
856            DEFAULT_LEVEL0_STOP_WRITE_THRESHOLD_MAX_SIZE
857        }
858
859        pub fn enable_optimize_l0_interval_selection() -> bool {
860            false
861        }
862    }
863}