Skip to main content

risingwave_common/config/
mod.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
15//! This pub module defines the structure of the configuration file `risingwave.toml`.
16//!
17//! [`RwConfig`] corresponds to the whole config file and each other config struct corresponds to a
18//! section in `risingwave.toml`.
19
20pub mod batch;
21pub use batch::BatchConfig;
22pub mod frontend;
23pub use frontend::FrontendConfig;
24pub mod hba;
25pub use hba::{AddressPattern, AuthMethod, ConnectionType, HbaConfig, HbaEntry};
26pub mod meta;
27pub use meta::{
28    CheckpointCompression, CompactionConfig, DefaultParallelism, MetaBackend, MetaConfig,
29    MetaStoreConfig,
30};
31pub mod streaming;
32pub use streaming::{AsyncStackTraceOption, StreamingConfig};
33pub mod server;
34pub use server::{HeapProfilingConfig, ServerConfig};
35
36pub use crate::session_config::SessionInitConfig;
37pub mod udf;
38pub use udf::UdfConfig;
39pub mod storage;
40pub use storage::{
41    CacheEvictionConfig, EvictionConfig, ObjectStoreConfig, StorageConfig, StorageMemoryConfig,
42    extract_storage_memory_config,
43};
44pub mod merge;
45pub mod mutate;
46pub mod none_as_empty_string;
47pub mod role;
48pub mod system;
49pub mod utils;
50use std::collections::BTreeMap;
51use std::fs;
52use std::num::NonZeroUsize;
53
54use anyhow::Context;
55use clap::ValueEnum;
56use educe::Educe;
57pub use merge::*;
58use risingwave_common_proc_macro::ConfigDoc;
59pub use risingwave_common_proc_macro::OverrideConfig;
60use risingwave_pb::meta::SystemParams;
61pub use role::*;
62use serde::{Deserialize, Serialize, Serializer};
63use serde_default::DefaultFromSerde;
64use serde_json::Value;
65pub use system::SystemConfig;
66pub use utils::*;
67
68use crate::for_all_params;
69
70/// Use the maximum value for HTTP/2 connection window size to avoid deadlock among multiplexed
71/// streams on the same connection.
72pub const MAX_CONNECTION_WINDOW_SIZE: u32 = (1 << 31) - 1;
73/// Use a large value for HTTP/2 stream window size to improve the performance of remote exchange,
74/// as we don't rely on this for back-pressure.
75pub const STREAM_WINDOW_SIZE: u32 = 32 * 1024 * 1024; // 32 MB
76
77/// [`RwConfig`] corresponds to the whole config file `risingwave.toml`. Each field corresponds to a
78/// section.
79#[derive(Educe, Clone, Serialize, Deserialize, Default, ConfigDoc)]
80#[educe(Debug)]
81pub struct RwConfig {
82    #[serde(default)]
83    #[config_doc(nested)]
84    pub server: ServerConfig,
85
86    #[serde(default)]
87    #[config_doc(nested)]
88    pub meta: MetaConfig,
89
90    #[serde(default)]
91    #[config_doc(nested)]
92    pub batch: BatchConfig,
93
94    #[serde(default)]
95    #[config_doc(nested)]
96    pub frontend: FrontendConfig,
97
98    #[serde(default)]
99    #[config_doc(nested)]
100    pub streaming: StreamingConfig,
101
102    #[serde(default)]
103    #[config_doc(nested)]
104    pub storage: StorageConfig,
105
106    #[serde(default)]
107    #[educe(Debug(ignore))]
108    #[config_doc(nested)]
109    pub system: SystemConfig,
110
111    #[serde(default)]
112    #[config_doc(nested)]
113    pub udf: UdfConfig,
114
115    #[serde(default)]
116    #[config_doc(nested)]
117    pub session_init: SessionInitConfig,
118
119    #[serde(flatten)]
120    #[config_doc(omitted)]
121    pub unrecognized: Unrecognized<Self>,
122}
123
124/// `[meta.developer.meta_compute_client_config]`
125/// `[meta.developer.meta_stream_client_config]`
126/// `[meta.developer.meta_frontend_client_config]`
127/// `[batch.developer.batch_compute_client_config]`
128/// `[batch.developer.batch_frontend_client_config]`
129/// `[streaming.developer.stream_compute_client_config]`
130#[serde_with::apply(Option => #[serde(with = "none_as_empty_string")])]
131#[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde, ConfigDoc)]
132pub struct RpcClientConfig {
133    #[serde(default = "default::developer::rpc_client_connect_timeout_secs")]
134    pub connect_timeout_secs: u64,
135    /// Maximum concurrency when setting up an RPC client pool.
136    /// Set to 0 to keep the previous unlimited behavior.
137    #[serde(default = "default::developer::rpc_client_pool_setup_concurrency")]
138    pub pool_setup_concurrency: usize,
139}
140
141pub use risingwave_common_metrics::MetricLevel;
142
143impl RwConfig {
144    pub const fn default_connection_pool_size(&self) -> u16 {
145        self.server.connection_pool_size
146    }
147
148    /// Returns [`streaming::StreamingDeveloperConfig::exchange_connection_pool_size`] if set,
149    /// otherwise [`ServerConfig::connection_pool_size`].
150    pub fn streaming_exchange_connection_pool_size(&self) -> u16 {
151        self.streaming
152            .developer
153            .exchange_connection_pool_size
154            .unwrap_or_else(|| self.default_connection_pool_size())
155    }
156
157    /// Returns [`batch::BatchDeveloperConfig::exchange_connection_pool_size`] if set,
158    /// otherwise [`ServerConfig::connection_pool_size`].
159    pub fn batch_exchange_connection_pool_size(&self) -> u16 {
160        self.batch
161            .developer
162            .exchange_connection_pool_size
163            .unwrap_or_else(|| self.default_connection_pool_size())
164    }
165}
166
167pub mod default {
168
169    pub mod developer {
170        use crate::config::streaming::CacheRefillPolicy;
171
172        pub fn meta_cached_traces_num() -> u32 {
173            256
174        }
175
176        pub fn meta_cached_traces_memory_limit_bytes() -> usize {
177            1 << 27 // 128 MiB
178        }
179
180        pub fn batch_output_channel_size() -> usize {
181            64
182        }
183
184        pub fn batch_receiver_channel_size() -> usize {
185            1000
186        }
187
188        pub fn batch_root_stage_channel_size() -> usize {
189            100
190        }
191
192        pub fn batch_chunk_size() -> usize {
193            1024
194        }
195
196        pub fn batch_local_execute_buffer_size() -> usize {
197            64
198        }
199
200        /// Default to unset to be compatible with the behavior before this config is introduced,
201        /// that is, follow the value of `server.connection_pool_size`.
202        pub fn batch_exchange_connection_pool_size() -> Option<u16> {
203            None
204        }
205
206        pub fn stream_enable_executor_row_count() -> bool {
207            false
208        }
209
210        pub fn connector_message_buffer_size() -> usize {
211            16
212        }
213
214        pub fn unsafe_stream_extreme_cache_size() -> usize {
215            10
216        }
217
218        pub fn stream_topn_cache_min_capacity() -> usize {
219            10
220        }
221
222        pub fn stream_chunk_size() -> usize {
223            256
224        }
225
226        pub fn stream_exchange_initial_permits() -> usize {
227            2048
228        }
229
230        pub fn stream_exchange_batched_permits() -> usize {
231            256
232        }
233
234        pub fn stream_exchange_concurrent_barriers() -> usize {
235            1
236        }
237
238        pub fn stream_exchange_concurrent_dispatchers() -> usize {
239            0
240        }
241
242        pub fn stream_project_expr_concurrency() -> usize {
243            1
244        }
245
246        pub fn stream_project_expr_inflight_request_concurrency() -> usize {
247            0
248        }
249
250        pub fn stream_dml_channel_initial_permits() -> usize {
251            32768
252        }
253
254        pub fn stream_max_barrier_batch_size() -> u32 {
255            1024
256        }
257
258        pub fn stream_hash_agg_max_dirty_groups_heap_size() -> usize {
259            64 << 20 // 64MB
260        }
261
262        pub fn enable_trivial_move() -> bool {
263            true
264        }
265
266        pub fn enable_check_task_level_overlap() -> bool {
267            false
268        }
269
270        pub fn max_trivial_move_task_count_per_loop() -> usize {
271            256
272        }
273
274        pub fn max_get_task_probe_times() -> usize {
275            5
276        }
277
278        pub fn actor_cnt_per_worker_parallelism_soft_limit() -> usize {
279            100
280        }
281
282        pub fn actor_cnt_per_worker_parallelism_hard_limit() -> usize {
283            400
284        }
285
286        pub fn hummock_time_travel_sst_info_fetch_batch_size() -> usize {
287            10_000
288        }
289
290        pub fn hummock_time_travel_sst_info_insert_batch_size() -> usize {
291            100
292        }
293
294        pub fn time_travel_vacuum_interval_sec() -> u64 {
295            30
296        }
297
298        pub fn time_travel_vacuum_max_version_count() -> Option<u32> {
299            Some(10000)
300        }
301
302        pub fn hummock_time_travel_epoch_version_insert_batch_size() -> usize {
303            1000
304        }
305
306        pub fn hummock_time_travel_delta_fetch_batch_size() -> usize {
307            100
308        }
309
310        pub fn hummock_gc_history_insert_batch_size() -> usize {
311            1000
312        }
313
314        pub fn hummock_time_travel_filter_out_objects_batch_size() -> usize {
315            1000
316        }
317
318        pub fn hummock_time_travel_filter_out_objects_v1() -> bool {
319            false
320        }
321
322        pub fn hummock_time_travel_filter_out_objects_list_version_batch_size() -> usize {
323            10
324        }
325
326        pub fn hummock_time_travel_filter_out_objects_list_delta_batch_size() -> usize {
327            1000
328        }
329
330        pub fn memory_controller_threshold_aggressive() -> f64 {
331            0.9
332        }
333
334        pub fn memory_controller_threshold_graceful() -> f64 {
335            0.81
336        }
337
338        pub fn memory_controller_threshold_stable() -> f64 {
339            0.72
340        }
341
342        pub fn memory_controller_eviction_factor_aggressive() -> f64 {
343            2.0
344        }
345
346        pub fn memory_controller_eviction_factor_graceful() -> f64 {
347            1.5
348        }
349
350        pub fn memory_controller_eviction_factor_stable() -> f64 {
351            1.0
352        }
353
354        pub fn memory_controller_update_interval_ms() -> usize {
355            100
356        }
357
358        pub fn memory_controller_sequence_tls_step() -> u64 {
359            128
360        }
361
362        pub fn memory_controller_sequence_tls_lag() -> u64 {
363            32
364        }
365
366        pub fn stream_enable_arrangement_backfill() -> bool {
367            true
368        }
369
370        pub fn stream_enable_snapshot_backfill() -> bool {
371            true
372        }
373
374        pub fn enable_shared_source() -> bool {
375            true
376        }
377
378        pub fn stream_high_join_amplification_threshold() -> usize {
379            2048
380        }
381
382        pub fn stream_high_gap_fill_amplification_threshold() -> usize {
383            2048
384        }
385
386        /// Default to 1 to be compatible with the behavior before this config is introduced.
387        pub fn stream_exchange_connection_pool_size() -> Option<u16> {
388            Some(1)
389        }
390
391        pub fn enable_actor_tokio_metrics() -> bool {
392            true
393        }
394
395        pub fn stream_enable_auto_schema_change() -> bool {
396            true
397        }
398
399        pub fn switch_jdbc_pg_to_native() -> bool {
400            false
401        }
402
403        pub fn streaming_hash_join_entry_state_max_rows() -> usize {
404            // NOTE(kwannoel): This is just an arbitrary number.
405            30000
406        }
407
408        pub fn streaming_join_hash_map_evict_interval_rows() -> u32 {
409            16
410        }
411
412        pub fn streaming_now_progress_ratio() -> Option<f32> {
413            None
414        }
415
416        pub fn stream_snapshot_iter_rebuild_interval_secs() -> u64 {
417            10 * 60
418        }
419
420        pub fn enable_explain_analyze_stats() -> bool {
421            true
422        }
423
424        pub fn rpc_client_connect_timeout_secs() -> u64 {
425            5
426        }
427
428        pub fn rpc_client_pool_setup_concurrency() -> usize {
429            0
430        }
431
432        pub fn iceberg_list_interval_sec() -> u64 {
433            10
434        }
435
436        pub fn iceberg_fetch_batch_size() -> u64 {
437            1024
438        }
439
440        pub fn iceberg_sink_positional_delete_cache_size() -> usize {
441            1024
442        }
443
444        pub fn iceberg_sink_write_parquet_max_row_group_rows() -> usize {
445            100_000
446        }
447
448        pub fn materialize_force_overwrite_on_no_check() -> bool {
449            false
450        }
451
452        pub fn refresh_scheduler_interval_sec() -> u64 {
453            60
454        }
455
456        pub fn sync_log_store_pause_duration_ms() -> usize {
457            64
458        }
459
460        pub fn sync_log_store_buffer_size() -> usize {
461            2048
462        }
463
464        pub fn disable_sync_log_store_dispatcher() -> bool {
465            false
466        }
467
468        pub fn table_change_log_insert_batch_size() -> u64 {
469            1000
470        }
471
472        pub fn table_change_log_delete_batch_size() -> u64 {
473            1000
474        }
475
476        pub fn table_change_log_truncate_interval_sec() -> u64 {
477            600
478        }
479
480        pub fn enable_state_table_vnode_stats_pruning() -> bool {
481            false
482        }
483
484        pub fn cache_refill_policy() -> CacheRefillPolicy {
485            CacheRefillPolicy::Enabled
486        }
487
488        pub fn enable_vnode_key_stats_for_materialize() -> bool {
489            false
490        }
491
492        pub fn max_concurrent_kv_log_store_historical_read() -> usize {
493            0
494        }
495    }
496}
497
498pub const MAX_META_CACHE_SHARD_BITS: usize = 4;
499pub const MIN_BUFFER_SIZE_PER_SHARD: usize = 256;
500pub const MAX_BLOCK_CACHE_SHARD_BITS: usize = 6; // It means that there will be 64 shards lru-cache to avoid lock conflict.
501
502#[cfg(test)]
503pub mod tests {
504    use expect_test::expect;
505    use risingwave_license::LicenseKey;
506
507    use super::*;
508
509    fn default_config_for_docs() -> RwConfig {
510        let mut config = RwConfig::default();
511        // Set `license_key` to empty in the docs to avoid any confusion.
512        config.system.license_key = Some(LicenseKey::empty());
513        // Keep generated docs and example config aligned with the production-safe default.
514        config.frontend.unsafe_enable_local_fs_connector = false;
515        config
516    }
517
518    /// This test ensures that `config/example.toml` is up-to-date with the default values specified
519    /// in this file. Developer should run `./risedev generate-example-config` to update it if this
520    /// test fails.
521    #[test]
522    fn test_example_up_to_date() {
523        const HEADER: &str = "# This file is generated by ./risedev generate-example-config
524# Check detailed comments in src/common/src/config.rs";
525
526        let actual = expect_test::expect_file!["../../../config/example.toml"];
527        let default = toml::to_string(&default_config_for_docs()).expect("failed to serialize");
528
529        let expected = format!("{HEADER}\n\n{default}");
530        actual.assert_eq(&expected);
531
532        let expected = rw_config_to_markdown();
533        let actual = expect_test::expect_file!["../../../config/docs.md"];
534        actual.assert_eq(&expected);
535    }
536
537    #[test]
538    fn test_session_init_entries_distinguishes_omitted_from_default() {
539        let config: RwConfig = toml::from_str(
540            r#"
541            [session_init]
542            streaming_parallelism = "bounded(8)"
543            streaming_parallelism_for_table = "default"
544            "#,
545        )
546        .unwrap();
547
548        // Omitted fields are `None`; an explicit `default` is `Some("default")`.
549        assert_eq!(
550            config.session_init.streaming_parallelism.as_deref(),
551            Some("bounded(8)")
552        );
553        assert_eq!(
554            config
555                .session_init
556                .streaming_parallelism_for_table
557                .as_deref(),
558            Some("default")
559        );
560        assert_eq!(config.session_init.streaming_parallelism_for_sink, None);
561
562        // Only explicitly-configured parameters are reported, by their session parameter name.
563        assert_eq!(
564            config.session_init.entries(),
565            vec![
566                ("streaming_parallelism", "bounded(8)"),
567                ("streaming_parallelism_for_table", "default"),
568            ]
569        );
570    }
571
572    #[test]
573    fn test_session_init_rejects_unrecognized_key() {
574        let err = toml::from_str::<RwConfig>(
575            r#"
576            [session_init]
577            streaming_parallelism = "bounded(8)"
578            not_a_real_param = "oops"
579            "#,
580        )
581        .unwrap_err();
582
583        assert!(err.to_string().contains("unknown field `not_a_real_param`"));
584    }
585
586    #[derive(Debug)]
587    struct ConfigItemDoc {
588        desc: String,
589        default: String,
590    }
591
592    fn rw_config_to_markdown() -> String {
593        let mut config_rustdocs = BTreeMap::<String, Vec<(String, String)>>::new();
594        RwConfig::config_docs("".to_owned(), &mut config_rustdocs);
595
596        // Section -> Config Name -> ConfigItemDoc
597        let mut configs: BTreeMap<String, BTreeMap<String, ConfigItemDoc>> = config_rustdocs
598            .into_iter()
599            .map(|(k, v)| {
600                let docs: BTreeMap<String, ConfigItemDoc> = v
601                    .into_iter()
602                    .map(|(name, desc)| {
603                        (
604                            name,
605                            ConfigItemDoc {
606                                desc,
607                                default: "".to_owned(), // unset
608                            },
609                        )
610                    })
611                    .collect();
612                (k, docs)
613            })
614            .collect();
615
616        let toml_doc: BTreeMap<String, toml::Value> =
617            toml::from_str(&toml::to_string(&default_config_for_docs()).unwrap()).unwrap();
618        toml_doc.into_iter().for_each(|(name, value)| {
619            set_default_values("".to_owned(), name, value, &mut configs);
620        });
621
622        let mut markdown = "# RisingWave System Configurations\n\n".to_owned()
623            + "This page is automatically generated by `./risedev generate-example-config`\n";
624        for (section, configs) in configs {
625            if configs.is_empty() {
626                continue;
627            }
628            markdown.push_str(&format!("\n## {}\n\n", section));
629            markdown.push_str("| Config | Description | Default |\n");
630            markdown.push_str("|--------|-------------|---------|\n");
631            for (config, doc) in configs {
632                markdown.push_str(&format!(
633                    "| {} | {} | {} |\n",
634                    config, doc.desc, doc.default
635                ));
636            }
637        }
638        markdown
639    }
640
641    fn set_default_values(
642        section: String,
643        name: String,
644        value: toml::Value,
645        configs: &mut BTreeMap<String, BTreeMap<String, ConfigItemDoc>>,
646    ) {
647        // Set the default value if it's a config name-value pair, otherwise it's a sub-section (Table) that should be recursively processed.
648        if let toml::Value::Table(table) = value {
649            let section_configs: BTreeMap<String, toml::Value> = table.into_iter().collect();
650            let sub_section = if section.is_empty() {
651                name
652            } else {
653                format!("{}.{}", section, name)
654            };
655            section_configs
656                .into_iter()
657                .for_each(|(k, v)| set_default_values(sub_section.clone(), k, v, configs))
658        } else if let Some(t) = configs.get_mut(&section)
659            && let Some(item_doc) = t.get_mut(&name)
660        {
661            item_doc.default = format!("{}", value);
662        }
663    }
664
665    #[test]
666    fn test_object_store_configs_backward_compatibility() {
667        // Define configs with the old name and make sure it still works
668        {
669            let config: RwConfig = toml::from_str(
670                r#"
671            [storage.object_store]
672            object_store_set_atomic_write_dir = true
673
674            [storage.object_store.s3]
675            object_store_keepalive_ms = 1
676            object_store_send_buffer_size = 1
677            object_store_recv_buffer_size = 1
678            object_store_nodelay = false
679
680            [storage.object_store.s3.developer]
681            object_store_retry_unknown_service_error = true
682            object_store_retryable_service_error_codes = ['dummy']
683
684
685            "#,
686            )
687            .unwrap();
688
689            assert!(config.storage.object_store.set_atomic_write_dir);
690            assert_eq!(config.storage.object_store.s3.keepalive_ms, Some(1));
691            assert_eq!(config.storage.object_store.s3.send_buffer_size, Some(1));
692            assert_eq!(config.storage.object_store.s3.recv_buffer_size, Some(1));
693            assert_eq!(config.storage.object_store.s3.nodelay, Some(false));
694            assert!(
695                config
696                    .storage
697                    .object_store
698                    .s3
699                    .developer
700                    .retry_unknown_service_error
701            );
702            assert_eq!(
703                config
704                    .storage
705                    .object_store
706                    .s3
707                    .developer
708                    .retryable_service_error_codes,
709                vec!["dummy".to_owned()]
710            );
711        }
712
713        // Define configs with the new name and make sure it works
714        {
715            let config: RwConfig = toml::from_str(
716                r#"
717            [storage.object_store]
718            set_atomic_write_dir = true
719
720            [storage.object_store.s3]
721            keepalive_ms = 1
722            send_buffer_size = 1
723            recv_buffer_size = 1
724            nodelay = false
725
726            [storage.object_store.s3.developer]
727            retry_unknown_service_error = true
728            retryable_service_error_codes = ['dummy']
729
730
731            "#,
732            )
733            .unwrap();
734
735            assert!(config.storage.object_store.set_atomic_write_dir);
736            assert_eq!(config.storage.object_store.s3.keepalive_ms, Some(1));
737            assert_eq!(config.storage.object_store.s3.send_buffer_size, Some(1));
738            assert_eq!(config.storage.object_store.s3.recv_buffer_size, Some(1));
739            assert_eq!(config.storage.object_store.s3.nodelay, Some(false));
740            assert!(
741                config
742                    .storage
743                    .object_store
744                    .s3
745                    .developer
746                    .retry_unknown_service_error
747            );
748            assert_eq!(
749                config
750                    .storage
751                    .object_store
752                    .s3
753                    .developer
754                    .retryable_service_error_codes,
755                vec!["dummy".to_owned()]
756            );
757        }
758    }
759
760    #[test]
761    fn test_file_cache_separated_runtime_config_backward_compatibility() {
762        let config: RwConfig = toml::from_str(
763            r#"
764            [storage.data_file_cache.runtime_config.Separated.read_runtime_options]
765            worker_threads = 2
766            max_blocking_threads = 4
767
768            [storage.data_file_cache.runtime_config.Separated.write_runtime_options]
769            worker_threads = 6
770            max_blocking_threads = 8
771            "#,
772        )
773        .unwrap();
774
775        let storage::FileCacheRuntimeConfig::Separated {
776            read_runtime_options,
777            write_runtime_options,
778        } = config.storage.data_file_cache.runtime_config
779        else {
780            panic!("expected legacy separated file-cache runtime config");
781        };
782        assert_eq!(read_runtime_options.worker_threads, 2);
783        assert_eq!(read_runtime_options.max_blocking_threads, 4);
784        assert_eq!(write_runtime_options.worker_threads, 6);
785        assert_eq!(write_runtime_options.max_blocking_threads, 8);
786    }
787
788    #[test]
789    fn test_meta_configs_backward_compatibility() {
790        // Test periodic_space_reclaim_compaction_interval_sec
791        {
792            let config: RwConfig = toml::from_str(
793                r#"
794            [meta]
795            periodic_split_compact_group_interval_sec = 1
796            table_write_throughput_threshold = 10
797            min_table_split_write_throughput = 5
798            "#,
799            )
800            .unwrap();
801
802            assert_eq!(
803                config
804                    .meta
805                    .periodic_scheduling_compaction_group_split_interval_sec,
806                1
807            );
808            assert_eq!(config.meta.table_high_write_throughput_threshold, 10);
809            assert_eq!(config.meta.table_low_write_throughput_threshold, 5);
810        }
811    }
812
813    #[test]
814    fn test_meta_max_normalize_splits_per_round_must_be_positive() {
815        let config = toml::from_str::<RwConfig>(
816            r#"
817            [meta]
818            max_normalize_splits_per_round = 0
819            "#,
820        )
821        .unwrap_err();
822
823        expect![[r#"
824            TOML parse error at line 3, column 46
825              |
826            3 |             max_normalize_splits_per_round = 0
827              |                                              ^
828            meta.max_normalize_splits_per_round must be greater than 0
829        "#]]
830        .assert_eq(&config.to_string());
831    }
832
833    // Previously, we have prefixes like `stream_` for all configs under `streaming.developer`.
834    // Later we removed the prefixes, but we still want to guarantee the backward compatibility.
835    #[test]
836    fn test_prefix_alias() {
837        let config: RwConfig = toml::from_str(
838            "
839            [streaming.developer]
840            stream_chunk_size = 114514
841
842            [streaming.developer.stream_compute_client_config]
843            connect_timeout_secs = 42
844            pool_setup_concurrency = 10
845            ",
846        )
847        .unwrap();
848
849        assert_eq!(config.streaming.developer.chunk_size, 114514);
850        assert_eq!(
851            config
852                .streaming
853                .developer
854                .compute_client_config
855                .connect_timeout_secs,
856            42
857        );
858        assert_eq!(
859            config
860                .streaming
861                .developer
862                .compute_client_config
863                .pool_setup_concurrency,
864            10
865        );
866    }
867
868    #[test]
869    fn test_prefix_alias_duplicate() {
870        let config = toml::from_str::<RwConfig>(
871            "
872            [streaming.developer]
873            stream_chunk_size = 114514
874            chunk_size = 1919810
875            ",
876        )
877        .unwrap_err();
878
879        expect![[r#"
880            TOML parse error at line 2, column 13
881              |
882            2 |             [streaming.developer]
883              |             ^^^^^^^^^^^^^^^^^^^^^
884            duplicate field `chunk_size`
885        "#]]
886        .assert_eq(&config.to_string());
887
888        let config = toml::from_str::<RwConfig>(
889            "
890            [streaming.developer.stream_compute_client_config]
891            connect_timeout_secs = 5
892
893            [streaming.developer.compute_client_config]
894            connect_timeout_secs = 10
895            ",
896        )
897        .unwrap_err();
898
899        expect![[r#"
900            TOML parse error at line 2, column 24
901              |
902            2 |             [streaming.developer.stream_compute_client_config]
903              |                        ^^^^^^^^^
904            duplicate field `compute_client_config`
905        "#]]
906        .assert_eq(&config.to_string());
907    }
908
909    #[test]
910    fn test_storage_max_prefetch_block_number_must_be_positive() {
911        let config = toml::from_str::<RwConfig>(
912            r#"
913            [storage]
914            max_prefetch_block_number = 0
915            "#,
916        )
917        .unwrap_err();
918
919        expect![[r#"
920            TOML parse error at line 3, column 41
921              |
922            3 |             max_prefetch_block_number = 0
923              |                                         ^
924            storage.max_prefetch_block_number must be greater than 0
925        "#]]
926        .assert_eq(&config.to_string());
927    }
928
929    #[test]
930    fn test_storage_iceberg_compaction_pull_interval_ms_must_be_positive() {
931        let config = toml::from_str::<RwConfig>(
932            r#"
933            [storage]
934            iceberg_compaction_pull_interval_ms = 0
935            "#,
936        )
937        .unwrap_err();
938
939        expect![[r#"
940            TOML parse error at line 3, column 51
941              |
942            3 |             iceberg_compaction_pull_interval_ms = 0
943              |                                                   ^
944            storage.iceberg_compaction_pull_interval_ms must be greater than 0
945        "#]]
946        .assert_eq(&config.to_string());
947    }
948}