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