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 streaming_now_progress_ratio() -> Option<f32> {
356 None
357 }
358
359 pub fn enable_explain_analyze_stats() -> bool {
360 true
361 }
362
363 pub fn rpc_client_connect_timeout_secs() -> u64 {
364 5
365 }
366
367 pub fn iceberg_list_interval_sec() -> u64 {
368 1
369 }
370
371 pub fn iceberg_fetch_batch_size() -> u64 {
372 1024
373 }
374
375 pub fn iceberg_sink_positional_delete_cache_size() -> usize {
376 1024
377 }
378
379 pub fn iceberg_sink_write_parquet_max_row_group_rows() -> usize {
380 100_000
381 }
382 }
383}
384
385pub const MAX_META_CACHE_SHARD_BITS: usize = 4;
386pub const MIN_BUFFER_SIZE_PER_SHARD: usize = 256;
387pub const MAX_BLOCK_CACHE_SHARD_BITS: usize = 6; #[cfg(test)]
390pub mod tests {
391 use risingwave_license::LicenseKey;
392
393 use super::*;
394
395 fn default_config_for_docs() -> RwConfig {
396 let mut config = RwConfig::default();
397 config.system.license_key = Some(LicenseKey::empty());
399 config
400 }
401
402 #[test]
406 fn test_example_up_to_date() {
407 const HEADER: &str = "# This file is generated by ./risedev generate-example-config
408# Check detailed comments in src/common/src/config.rs";
409
410 let actual = expect_test::expect_file!["../../../config/example.toml"];
411 let default = toml::to_string(&default_config_for_docs()).expect("failed to serialize");
412
413 let expected = format!("{HEADER}\n\n{default}");
414 actual.assert_eq(&expected);
415
416 let expected = rw_config_to_markdown();
417 let actual = expect_test::expect_file!["../../../config/docs.md"];
418 actual.assert_eq(&expected);
419 }
420
421 #[derive(Debug)]
422 struct ConfigItemDoc {
423 desc: String,
424 default: String,
425 }
426
427 fn rw_config_to_markdown() -> String {
428 let mut config_rustdocs = BTreeMap::<String, Vec<(String, String)>>::new();
429 RwConfig::config_docs("".to_owned(), &mut config_rustdocs);
430
431 let mut configs: BTreeMap<String, BTreeMap<String, ConfigItemDoc>> = config_rustdocs
433 .into_iter()
434 .map(|(k, v)| {
435 let docs: BTreeMap<String, ConfigItemDoc> = v
436 .into_iter()
437 .map(|(name, desc)| {
438 (
439 name,
440 ConfigItemDoc {
441 desc,
442 default: "".to_owned(), },
444 )
445 })
446 .collect();
447 (k, docs)
448 })
449 .collect();
450
451 let toml_doc: BTreeMap<String, toml::Value> =
452 toml::from_str(&toml::to_string(&default_config_for_docs()).unwrap()).unwrap();
453 toml_doc.into_iter().for_each(|(name, value)| {
454 set_default_values("".to_owned(), name, value, &mut configs);
455 });
456
457 let mut markdown = "# RisingWave System Configurations\n\n".to_owned()
458 + "This page is automatically generated by `./risedev generate-example-config`\n";
459 for (section, configs) in configs {
460 if configs.is_empty() {
461 continue;
462 }
463 markdown.push_str(&format!("\n## {}\n\n", section));
464 markdown.push_str("| Config | Description | Default |\n");
465 markdown.push_str("|--------|-------------|---------|\n");
466 for (config, doc) in configs {
467 markdown.push_str(&format!(
468 "| {} | {} | {} |\n",
469 config, doc.desc, doc.default
470 ));
471 }
472 }
473 markdown
474 }
475
476 fn set_default_values(
477 section: String,
478 name: String,
479 value: toml::Value,
480 configs: &mut BTreeMap<String, BTreeMap<String, ConfigItemDoc>>,
481 ) {
482 if let toml::Value::Table(table) = value {
484 let section_configs: BTreeMap<String, toml::Value> =
485 table.clone().into_iter().collect();
486 let sub_section = if section.is_empty() {
487 name
488 } else {
489 format!("{}.{}", section, name)
490 };
491 section_configs
492 .into_iter()
493 .for_each(|(k, v)| set_default_values(sub_section.clone(), k, v, configs))
494 } else if let Some(t) = configs.get_mut(§ion)
495 && let Some(item_doc) = t.get_mut(&name)
496 {
497 item_doc.default = format!("{}", value);
498 }
499 }
500
501 #[test]
502 fn test_object_store_configs_backward_compatibility() {
503 {
505 let config: RwConfig = toml::from_str(
506 r#"
507 [storage.object_store]
508 object_store_set_atomic_write_dir = true
509
510 [storage.object_store.s3]
511 object_store_keepalive_ms = 1
512 object_store_send_buffer_size = 1
513 object_store_recv_buffer_size = 1
514 object_store_nodelay = false
515
516 [storage.object_store.s3.developer]
517 object_store_retry_unknown_service_error = true
518 object_store_retryable_service_error_codes = ['dummy']
519
520
521 "#,
522 )
523 .unwrap();
524
525 assert!(config.storage.object_store.set_atomic_write_dir);
526 assert_eq!(config.storage.object_store.s3.keepalive_ms, Some(1));
527 assert_eq!(config.storage.object_store.s3.send_buffer_size, Some(1));
528 assert_eq!(config.storage.object_store.s3.recv_buffer_size, Some(1));
529 assert_eq!(config.storage.object_store.s3.nodelay, Some(false));
530 assert!(
531 config
532 .storage
533 .object_store
534 .s3
535 .developer
536 .retry_unknown_service_error
537 );
538 assert_eq!(
539 config
540 .storage
541 .object_store
542 .s3
543 .developer
544 .retryable_service_error_codes,
545 vec!["dummy".to_owned()]
546 );
547 }
548
549 {
551 let config: RwConfig = toml::from_str(
552 r#"
553 [storage.object_store]
554 set_atomic_write_dir = true
555
556 [storage.object_store.s3]
557 keepalive_ms = 1
558 send_buffer_size = 1
559 recv_buffer_size = 1
560 nodelay = false
561
562 [storage.object_store.s3.developer]
563 retry_unknown_service_error = true
564 retryable_service_error_codes = ['dummy']
565
566
567 "#,
568 )
569 .unwrap();
570
571 assert!(config.storage.object_store.set_atomic_write_dir);
572 assert_eq!(config.storage.object_store.s3.keepalive_ms, Some(1));
573 assert_eq!(config.storage.object_store.s3.send_buffer_size, Some(1));
574 assert_eq!(config.storage.object_store.s3.recv_buffer_size, Some(1));
575 assert_eq!(config.storage.object_store.s3.nodelay, Some(false));
576 assert!(
577 config
578 .storage
579 .object_store
580 .s3
581 .developer
582 .retry_unknown_service_error
583 );
584 assert_eq!(
585 config
586 .storage
587 .object_store
588 .s3
589 .developer
590 .retryable_service_error_codes,
591 vec!["dummy".to_owned()]
592 );
593 }
594 }
595
596 #[test]
597 fn test_meta_configs_backward_compatibility() {
598 {
600 let config: RwConfig = toml::from_str(
601 r#"
602 [meta]
603 periodic_split_compact_group_interval_sec = 1
604 table_write_throughput_threshold = 10
605 min_table_split_write_throughput = 5
606 "#,
607 )
608 .unwrap();
609
610 assert_eq!(
611 config
612 .meta
613 .periodic_scheduling_compaction_group_split_interval_sec,
614 1
615 );
616 assert_eq!(config.meta.table_high_write_throughput_threshold, 10);
617 assert_eq!(config.meta.table_low_write_throughput_threshold, 5);
618 }
619 }
620}