risingwave_common/config/
mod.rs1pub mod batch;
21pub use batch::BatchConfig;
22pub mod frontend;
23pub use frontend::FrontendConfig;
24pub mod meta;
25pub use meta::{CompactionConfig, DefaultParallelism, MetaBackend, MetaConfig, MetaStoreConfig};
26pub mod streaming;
27pub use streaming::{AsyncStackTraceOption, StreamingConfig};
28pub mod server;
29pub use server::{HeapProfilingConfig, ServerConfig};
30pub mod udf;
31pub use udf::UdfConfig;
32pub mod storage;
33pub use storage::{
34 CacheEvictionConfig, EvictionConfig, ObjectStoreConfig, StorageConfig, StorageMemoryConfig,
35 extract_storage_memory_config,
36};
37pub mod system;
38pub mod utils;
39use std::collections::BTreeMap;
40use std::fs;
41use std::num::NonZeroUsize;
42
43use anyhow::Context;
44use clap::ValueEnum;
45use educe::Educe;
46use risingwave_common_proc_macro::ConfigDoc;
47pub use risingwave_common_proc_macro::OverrideConfig;
48use risingwave_pb::meta::SystemParams;
49use serde::{Deserialize, Serialize, Serializer};
50use serde_default::DefaultFromSerde;
51use serde_json::Value;
52pub use system::SystemConfig;
53pub use utils::*;
54
55use crate::for_all_params;
56
57pub const MAX_CONNECTION_WINDOW_SIZE: u32 = (1 << 31) - 1;
60pub const STREAM_WINDOW_SIZE: u32 = 32 * 1024 * 1024; #[derive(Educe, Clone, Serialize, Deserialize, Default, ConfigDoc)]
67#[educe(Debug)]
68pub struct RwConfig {
69 #[serde(default)]
70 #[config_doc(nested)]
71 pub server: ServerConfig,
72
73 #[serde(default)]
74 #[config_doc(nested)]
75 pub meta: MetaConfig,
76
77 #[serde(default)]
78 #[config_doc(nested)]
79 pub batch: BatchConfig,
80
81 #[serde(default)]
82 #[config_doc(nested)]
83 pub frontend: FrontendConfig,
84
85 #[serde(default)]
86 #[config_doc(nested)]
87 pub streaming: StreamingConfig,
88
89 #[serde(default)]
90 #[config_doc(nested)]
91 pub storage: StorageConfig,
92
93 #[serde(default)]
94 #[educe(Debug(ignore))]
95 #[config_doc(nested)]
96 pub system: SystemConfig,
97
98 #[serde(default)]
99 #[config_doc(nested)]
100 pub udf: UdfConfig,
101
102 #[serde(flatten)]
103 #[config_doc(omitted)]
104 pub unrecognized: Unrecognized<Self>,
105}
106
107#[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde, ConfigDoc)]
114pub struct RpcClientConfig {
115 #[serde(default = "default::developer::rpc_client_connect_timeout_secs")]
116 pub connect_timeout_secs: u64,
117}
118
119pub use risingwave_common_metrics::MetricLevel;
120
121impl RwConfig {
122 pub const fn default_connection_pool_size(&self) -> u16 {
123 self.server.connection_pool_size
124 }
125
126 pub fn streaming_exchange_connection_pool_size(&self) -> u16 {
129 self.streaming
130 .developer
131 .exchange_connection_pool_size
132 .unwrap_or_else(|| self.default_connection_pool_size())
133 }
134
135 pub fn batch_exchange_connection_pool_size(&self) -> u16 {
138 self.batch
139 .developer
140 .exchange_connection_pool_size
141 .unwrap_or_else(|| self.default_connection_pool_size())
142 }
143}
144
145pub mod default {
146
147 pub mod developer {
148 pub fn meta_cached_traces_num() -> u32 {
149 256
150 }
151
152 pub fn meta_cached_traces_memory_limit_bytes() -> usize {
153 1 << 27 }
155
156 pub fn batch_output_channel_size() -> usize {
157 64
158 }
159
160 pub fn batch_receiver_channel_size() -> usize {
161 1000
162 }
163
164 pub fn batch_root_stage_channel_size() -> usize {
165 100
166 }
167
168 pub fn batch_chunk_size() -> usize {
169 1024
170 }
171
172 pub fn batch_local_execute_buffer_size() -> usize {
173 64
174 }
175
176 pub fn batch_exchange_connection_pool_size() -> Option<u16> {
179 None
180 }
181
182 pub fn stream_enable_executor_row_count() -> bool {
183 false
184 }
185
186 pub fn connector_message_buffer_size() -> usize {
187 16
188 }
189
190 pub fn unsafe_stream_extreme_cache_size() -> usize {
191 10
192 }
193
194 pub fn stream_chunk_size() -> usize {
195 256
196 }
197
198 pub fn stream_exchange_initial_permits() -> usize {
199 2048
200 }
201
202 pub fn stream_exchange_batched_permits() -> usize {
203 256
204 }
205
206 pub fn stream_exchange_concurrent_barriers() -> usize {
207 1
208 }
209
210 pub fn stream_exchange_concurrent_dispatchers() -> usize {
211 0
212 }
213
214 pub fn stream_dml_channel_initial_permits() -> usize {
215 32768
216 }
217
218 pub fn stream_max_barrier_batch_size() -> u32 {
219 1024
220 }
221
222 pub fn stream_hash_agg_max_dirty_groups_heap_size() -> usize {
223 64 << 20 }
225
226 pub fn enable_trivial_move() -> bool {
227 true
228 }
229
230 pub fn enable_check_task_level_overlap() -> bool {
231 false
232 }
233
234 pub fn max_trivial_move_task_count_per_loop() -> usize {
235 256
236 }
237
238 pub fn max_get_task_probe_times() -> usize {
239 5
240 }
241
242 pub fn actor_cnt_per_worker_parallelism_soft_limit() -> usize {
243 100
244 }
245
246 pub fn actor_cnt_per_worker_parallelism_hard_limit() -> usize {
247 400
248 }
249
250 pub fn hummock_time_travel_sst_info_fetch_batch_size() -> usize {
251 10_000
252 }
253
254 pub fn hummock_time_travel_sst_info_insert_batch_size() -> usize {
255 100
256 }
257
258 pub fn time_travel_vacuum_interval_sec() -> u64 {
259 30
260 }
261 pub fn hummock_time_travel_epoch_version_insert_batch_size() -> usize {
262 1000
263 }
264
265 pub fn hummock_gc_history_insert_batch_size() -> usize {
266 1000
267 }
268
269 pub fn hummock_time_travel_filter_out_objects_batch_size() -> usize {
270 1000
271 }
272
273 pub fn hummock_time_travel_filter_out_objects_v1() -> bool {
274 false
275 }
276
277 pub fn hummock_time_travel_filter_out_objects_list_version_batch_size() -> usize {
278 10
279 }
280
281 pub fn hummock_time_travel_filter_out_objects_list_delta_batch_size() -> usize {
282 1000
283 }
284
285 pub fn memory_controller_threshold_aggressive() -> f64 {
286 0.9
287 }
288
289 pub fn memory_controller_threshold_graceful() -> f64 {
290 0.81
291 }
292
293 pub fn memory_controller_threshold_stable() -> f64 {
294 0.72
295 }
296
297 pub fn memory_controller_eviction_factor_aggressive() -> f64 {
298 2.0
299 }
300
301 pub fn memory_controller_eviction_factor_graceful() -> f64 {
302 1.5
303 }
304
305 pub fn memory_controller_eviction_factor_stable() -> f64 {
306 1.0
307 }
308
309 pub fn memory_controller_update_interval_ms() -> usize {
310 100
311 }
312
313 pub fn memory_controller_sequence_tls_step() -> u64 {
314 128
315 }
316
317 pub fn memory_controller_sequence_tls_lag() -> u64 {
318 32
319 }
320
321 pub fn stream_enable_arrangement_backfill() -> bool {
322 true
323 }
324
325 pub fn enable_shared_source() -> bool {
326 true
327 }
328
329 pub fn stream_high_join_amplification_threshold() -> usize {
330 2048
331 }
332
333 pub fn stream_exchange_connection_pool_size() -> Option<u16> {
335 Some(1)
336 }
337
338 pub fn enable_actor_tokio_metrics() -> bool {
339 false
340 }
341
342 pub fn stream_enable_auto_schema_change() -> bool {
343 true
344 }
345
346 pub fn switch_jdbc_pg_to_native() -> bool {
347 false
348 }
349
350 pub fn streaming_hash_join_entry_state_max_rows() -> usize {
351 30000
353 }
354
355 pub fn enable_explain_analyze_stats() -> bool {
356 true
357 }
358
359 pub fn rpc_client_connect_timeout_secs() -> u64 {
360 5
361 }
362
363 pub fn iceberg_list_interval_sec() -> u64 {
364 1
365 }
366
367 pub fn iceberg_fetch_batch_size() -> u64 {
368 1024
369 }
370
371 pub fn iceberg_sink_positional_delete_cache_size() -> usize {
372 1024
373 }
374
375 pub fn iceberg_sink_write_parquet_max_row_group_rows() -> usize {
376 100_000
377 }
378 }
379}
380
381pub const MAX_META_CACHE_SHARD_BITS: usize = 4;
382pub const MIN_BUFFER_SIZE_PER_SHARD: usize = 256;
383pub const MAX_BLOCK_CACHE_SHARD_BITS: usize = 6; #[cfg(test)]
386pub mod tests {
387 use risingwave_license::LicenseKey;
388
389 use super::*;
390
391 fn default_config_for_docs() -> RwConfig {
392 let mut config = RwConfig::default();
393 config.system.license_key = Some(LicenseKey::empty());
395 config
396 }
397
398 #[test]
402 fn test_example_up_to_date() {
403 const HEADER: &str = "# This file is generated by ./risedev generate-example-config
404# Check detailed comments in src/common/src/config.rs";
405
406 let actual = expect_test::expect_file!["../../../config/example.toml"];
407 let default = toml::to_string(&default_config_for_docs()).expect("failed to serialize");
408
409 let expected = format!("{HEADER}\n\n{default}");
410 actual.assert_eq(&expected);
411
412 let expected = rw_config_to_markdown();
413 let actual = expect_test::expect_file!["../../../config/docs.md"];
414 actual.assert_eq(&expected);
415 }
416
417 #[derive(Debug)]
418 struct ConfigItemDoc {
419 desc: String,
420 default: String,
421 }
422
423 fn rw_config_to_markdown() -> String {
424 let mut config_rustdocs = BTreeMap::<String, Vec<(String, String)>>::new();
425 RwConfig::config_docs("".to_owned(), &mut config_rustdocs);
426
427 let mut configs: BTreeMap<String, BTreeMap<String, ConfigItemDoc>> = config_rustdocs
429 .into_iter()
430 .map(|(k, v)| {
431 let docs: BTreeMap<String, ConfigItemDoc> = v
432 .into_iter()
433 .map(|(name, desc)| {
434 (
435 name,
436 ConfigItemDoc {
437 desc,
438 default: "".to_owned(), },
440 )
441 })
442 .collect();
443 (k, docs)
444 })
445 .collect();
446
447 let toml_doc: BTreeMap<String, toml::Value> =
448 toml::from_str(&toml::to_string(&default_config_for_docs()).unwrap()).unwrap();
449 toml_doc.into_iter().for_each(|(name, value)| {
450 set_default_values("".to_owned(), name, value, &mut configs);
451 });
452
453 let mut markdown = "# RisingWave System Configurations\n\n".to_owned()
454 + "This page is automatically generated by `./risedev generate-example-config`\n";
455 for (section, configs) in configs {
456 if configs.is_empty() {
457 continue;
458 }
459 markdown.push_str(&format!("\n## {}\n\n", section));
460 markdown.push_str("| Config | Description | Default |\n");
461 markdown.push_str("|--------|-------------|---------|\n");
462 for (config, doc) in configs {
463 markdown.push_str(&format!(
464 "| {} | {} | {} |\n",
465 config, doc.desc, doc.default
466 ));
467 }
468 }
469 markdown
470 }
471
472 fn set_default_values(
473 section: String,
474 name: String,
475 value: toml::Value,
476 configs: &mut BTreeMap<String, BTreeMap<String, ConfigItemDoc>>,
477 ) {
478 if let toml::Value::Table(table) = value {
480 let section_configs: BTreeMap<String, toml::Value> =
481 table.clone().into_iter().collect();
482 let sub_section = if section.is_empty() {
483 name
484 } else {
485 format!("{}.{}", section, name)
486 };
487 section_configs
488 .into_iter()
489 .for_each(|(k, v)| set_default_values(sub_section.clone(), k, v, configs))
490 } else if let Some(t) = configs.get_mut(§ion)
491 && let Some(item_doc) = t.get_mut(&name)
492 {
493 item_doc.default = format!("{}", value);
494 }
495 }
496
497 #[test]
498 fn test_object_store_configs_backward_compatibility() {
499 {
501 let config: RwConfig = toml::from_str(
502 r#"
503 [storage.object_store]
504 object_store_set_atomic_write_dir = true
505
506 [storage.object_store.s3]
507 object_store_keepalive_ms = 1
508 object_store_send_buffer_size = 1
509 object_store_recv_buffer_size = 1
510 object_store_nodelay = false
511
512 [storage.object_store.s3.developer]
513 object_store_retry_unknown_service_error = true
514 object_store_retryable_service_error_codes = ['dummy']
515
516
517 "#,
518 )
519 .unwrap();
520
521 assert!(config.storage.object_store.set_atomic_write_dir);
522 assert_eq!(config.storage.object_store.s3.keepalive_ms, Some(1));
523 assert_eq!(config.storage.object_store.s3.send_buffer_size, Some(1));
524 assert_eq!(config.storage.object_store.s3.recv_buffer_size, Some(1));
525 assert_eq!(config.storage.object_store.s3.nodelay, Some(false));
526 assert!(
527 config
528 .storage
529 .object_store
530 .s3
531 .developer
532 .retry_unknown_service_error
533 );
534 assert_eq!(
535 config
536 .storage
537 .object_store
538 .s3
539 .developer
540 .retryable_service_error_codes,
541 vec!["dummy".to_owned()]
542 );
543 }
544
545 {
547 let config: RwConfig = toml::from_str(
548 r#"
549 [storage.object_store]
550 set_atomic_write_dir = true
551
552 [storage.object_store.s3]
553 keepalive_ms = 1
554 send_buffer_size = 1
555 recv_buffer_size = 1
556 nodelay = false
557
558 [storage.object_store.s3.developer]
559 retry_unknown_service_error = true
560 retryable_service_error_codes = ['dummy']
561
562
563 "#,
564 )
565 .unwrap();
566
567 assert!(config.storage.object_store.set_atomic_write_dir);
568 assert_eq!(config.storage.object_store.s3.keepalive_ms, Some(1));
569 assert_eq!(config.storage.object_store.s3.send_buffer_size, Some(1));
570 assert_eq!(config.storage.object_store.s3.recv_buffer_size, Some(1));
571 assert_eq!(config.storage.object_store.s3.nodelay, Some(false));
572 assert!(
573 config
574 .storage
575 .object_store
576 .s3
577 .developer
578 .retry_unknown_service_error
579 );
580 assert_eq!(
581 config
582 .storage
583 .object_store
584 .s3
585 .developer
586 .retryable_service_error_codes,
587 vec!["dummy".to_owned()]
588 );
589 }
590 }
591
592 #[test]
593 fn test_meta_configs_backward_compatibility() {
594 {
596 let config: RwConfig = toml::from_str(
597 r#"
598 [meta]
599 periodic_split_compact_group_interval_sec = 1
600 table_write_throughput_threshold = 10
601 min_table_split_write_throughput = 5
602 "#,
603 )
604 .unwrap();
605
606 assert_eq!(
607 config
608 .meta
609 .periodic_scheduling_compaction_group_split_interval_sec,
610 1
611 );
612 assert_eq!(config.meta.table_high_write_throughput_threshold, 10);
613 assert_eq!(config.meta.table_low_write_throughput_threshold, 5);
614 }
615 }
616}