Skip to main content

risingwave_meta_node/
lib.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#![cfg_attr(coverage, feature(coverage_attribute))]
16
17mod server;
18
19use std::path::PathBuf;
20use std::time::Duration;
21
22use clap::Parser;
23use educe::Educe;
24pub use error::{MetaError, MetaResult};
25use redact::Secret;
26use risingwave_common::config::OverrideConfig;
27use risingwave_common::license::LicenseKey;
28use risingwave_common::system_param::StateStoreUrl;
29use risingwave_common::util::meta_addr::MetaAddressStrategy;
30use risingwave_common::util::resource_util;
31use risingwave_common::util::tokio_util::sync::CancellationToken;
32use risingwave_common::{GIT_SHA, RW_VERSION};
33use risingwave_common_heap_profiling::HeapProfiler;
34use risingwave_meta::*;
35use risingwave_meta_service::*;
36pub use rpc::{ElectionClient, ElectionMember};
37use server::rpc_serve;
38pub use server::started::get as is_server_started;
39
40use crate::manager::MetaOpts;
41
42#[derive(Educe, Clone, Parser, OverrideConfig)]
43#[educe(Debug)]
44#[command(version, about = "The central metadata management service")]
45pub struct MetaNodeOpts {
46    // TODO: use `SocketAddr`
47    #[clap(long, env = "RW_LISTEN_ADDR", default_value = "127.0.0.1:5690")]
48    pub listen_addr: String,
49
50    /// The address for contacting this instance of the service.
51    /// This would be synonymous with the service's "public address"
52    /// or "identifying address".
53    /// It will serve as a unique identifier in cluster
54    /// membership and leader election. Must be specified for meta backend.
55    #[clap(long, env = "RW_ADVERTISE_ADDR", default_value = "127.0.0.1:5690")]
56    pub advertise_addr: String,
57
58    #[clap(long, env = "RW_DASHBOARD_HOST")]
59    pub dashboard_host: Option<String>,
60
61    /// We will start a http server at this address via `MetricsManager`.
62    /// Then the prometheus instance will poll the metrics from this address.
63    #[clap(long, env = "RW_PROMETHEUS_HOST", alias = "prometheus-host")]
64    pub prometheus_listener_addr: Option<String>,
65
66    /// Endpoint of the SQL service, make it non-option when SQL service is required.
67    #[clap(long, hide = true, env = "RW_SQL_ENDPOINT")]
68    pub sql_endpoint: Option<Secret<String>>,
69
70    /// Username of sql backend, required when meta backend set to MySQL or PostgreSQL.
71    #[clap(long, hide = true, env = "RW_SQL_USERNAME", default_value = "")]
72    pub sql_username: String,
73
74    /// Password of sql backend, required when meta backend set to MySQL or PostgreSQL.
75    #[clap(long, hide = true, env = "RW_SQL_PASSWORD", default_value = "")]
76    pub sql_password: Secret<String>,
77
78    /// Database of sql backend, required when meta backend set to MySQL or PostgreSQL.
79    #[clap(long, hide = true, env = "RW_SQL_DATABASE", default_value = "")]
80    pub sql_database: String,
81
82    /// Params for the URL connection, such as `sslmode=disable`.
83    /// Example: `param1=value1&param2=value2`
84    #[clap(long, hide = true, env = "RW_SQL_URL_PARAMS")]
85    pub sql_url_params: Option<String>,
86
87    /// The HTTP REST-API address of the Prometheus instance associated to this cluster.
88    /// This address is used to serve `PromQL` queries to Prometheus.
89    /// It is also used by Grafana Dashboard Service to fetch metrics and visualize them.
90    #[clap(long, env = "RW_PROMETHEUS_ENDPOINT")]
91    pub prometheus_endpoint: Option<String>,
92
93    /// The additional selector used when querying Prometheus.
94    ///
95    /// The format is same as `PromQL`. Example: `instance="foo",namespace="bar"`
96    #[clap(long, env = "RW_PROMETHEUS_SELECTOR")]
97    pub prometheus_selector: Option<String>,
98
99    /// Default tag for the endpoint created when creating a privatelink connection.
100    /// Will be appended to the tags specified in the `tags` field in with clause in `create
101    /// connection`.
102    #[clap(long, hide = true, env = "RW_PRIVATELINK_ENDPOINT_DEFAULT_TAGS")]
103    pub privatelink_endpoint_default_tags: Option<String>,
104
105    #[clap(long, hide = true, env = "RW_VPC_ID")]
106    pub vpc_id: Option<String>,
107
108    #[clap(long, hide = true, env = "RW_VPC_SECURITY_GROUP_ID")]
109    pub security_group_id: Option<String>,
110
111    /// The path of `risingwave.toml` configuration file.
112    ///
113    /// If empty, default configuration values will be used.
114    #[clap(long, env = "RW_CONFIG_PATH", default_value = "")]
115    pub config_path: String,
116
117    #[clap(long, hide = true, env = "RW_BACKEND", value_enum)]
118    #[override_opts(path = meta.backend)]
119    pub backend: Option<MetaBackend>,
120
121    /// The interval of periodic barrier.
122    #[clap(long, hide = true, env = "RW_BARRIER_INTERVAL_MS")]
123    #[override_opts(path = system.barrier_interval_ms)]
124    pub barrier_interval_ms: Option<u32>,
125
126    /// Target size of the Sstable.
127    #[clap(long, hide = true, env = "RW_SSTABLE_SIZE_MB")]
128    #[override_opts(path = system.sstable_size_mb)]
129    pub sstable_size_mb: Option<u32>,
130
131    /// Size of each block in bytes in SST.
132    #[clap(long, hide = true, env = "RW_BLOCK_SIZE_KB")]
133    #[override_opts(path = system.block_size_kb)]
134    pub block_size_kb: Option<u32>,
135
136    /// Deprecated: Bloom filter is no longer a supported SST filter implementation.
137    #[clap(long, hide = true, env = "RW_BLOOM_FALSE_POSITIVE")]
138    #[override_opts(path = system.bloom_false_positive)]
139    pub bloom_false_positive: Option<f64>,
140
141    /// State store url
142    #[clap(long, hide = true, env = "RW_STATE_STORE")]
143    #[override_opts(path = system.state_store)]
144    pub state_store: Option<StateStoreUrl>,
145
146    /// Remote directory for storing data and metadata objects.
147    #[clap(long, hide = true, env = "RW_DATA_DIRECTORY")]
148    #[override_opts(path = system.data_directory)]
149    pub data_directory: Option<String>,
150
151    /// Whether config object storage bucket lifecycle to purge stale data.
152    #[clap(long, hide = true, env = "RW_DO_NOT_CONFIG_BUCKET_LIFECYCLE")]
153    #[override_opts(path = meta.do_not_config_object_storage_lifecycle)]
154    pub do_not_config_object_storage_lifecycle: Option<bool>,
155
156    /// Remote storage url for storing snapshots.
157    #[clap(long, hide = true, env = "RW_BACKUP_STORAGE_URL")]
158    #[override_opts(path = system.backup_storage_url)]
159    pub backup_storage_url: Option<String>,
160
161    /// Remote directory for storing snapshots.
162    #[clap(long, hide = true, env = "RW_BACKUP_STORAGE_DIRECTORY")]
163    #[override_opts(path = system.backup_storage_directory)]
164    pub backup_storage_directory: Option<String>,
165
166    /// Enable heap profile dump when memory usage is high.
167    #[clap(long, hide = true, env = "RW_HEAP_PROFILING_DIR")]
168    #[override_opts(path = server.heap_profiling.dir)]
169    pub heap_profiling_dir: Option<String>,
170
171    /// Exit if idle for a certain period of time.
172    #[clap(long, hide = true, env = "RW_DANGEROUS_MAX_IDLE_SECS")]
173    #[override_opts(path = meta.dangerous_max_idle_secs)]
174    pub dangerous_max_idle_secs: Option<u64>,
175
176    /// Endpoint of the connector node.
177    #[deprecated = "connector node has been deprecated."]
178    #[clap(long, hide = true, env = "RW_CONNECTOR_RPC_ENDPOINT")]
179    pub connector_rpc_endpoint: Option<String>,
180
181    /// The license key to activate enterprise features.
182    #[clap(long, hide = true, env = "RW_LICENSE_KEY")]
183    #[override_opts(path = system.license_key)]
184    pub license_key: Option<LicenseKey>,
185
186    /// The path of the license key file to be watched and hot-reloaded.
187    #[clap(long, env = "RW_LICENSE_KEY_PATH")]
188    pub license_key_path: Option<PathBuf>,
189
190    /// 128-bit AES key for secret store in HEX format.
191    #[educe(Debug(ignore))] // TODO: use newtype to redact debug impl
192    #[clap(long, hide = true, env = "RW_SECRET_STORE_PRIVATE_KEY_HEX")]
193    pub secret_store_private_key_hex: Option<String>,
194
195    /// The path of the temp secret file directory.
196    #[clap(
197        long,
198        hide = true,
199        env = "RW_TEMP_SECRET_FILE_DIR",
200        default_value = "./secrets"
201    )]
202    pub temp_secret_file_dir: String,
203
204    /// Address of the serverless backfill controller.
205    /// Needed if meta receives a streaming job with serverless backfill enabled.
206    /// Feature disabled by default.
207    #[clap(long, env = "RW_SBC_ADDR", default_value = "")]
208    pub serverless_backfill_controller_addr: String,
209}
210
211impl risingwave_common::opts::Opts for MetaNodeOpts {
212    fn name() -> &'static str {
213        "meta"
214    }
215
216    fn meta_addr(&self) -> MetaAddressStrategy {
217        format!("http://{}", self.listen_addr)
218            .parse()
219            .expect("invalid listen address")
220    }
221}
222
223use std::future::Future;
224use std::pin::Pin;
225use std::sync::Arc;
226
227use risingwave_common::config::{MetaBackend, RwConfig, load_config};
228use tracing::info;
229
230/// Start meta node
231pub fn start(
232    opts: MetaNodeOpts,
233    shutdown: CancellationToken,
234) -> Pin<Box<dyn Future<Output = ()> + Send>> {
235    // WARNING: don't change the function signature. Making it `async fn` will cause
236    // slow compile in release mode.
237    Box::pin(async move {
238        info!("Starting meta node");
239        info!("> options: {:?}", opts);
240        let config = load_config(&opts.config_path, &opts);
241        info!("> config: {:?}", config);
242        info!("> version: {} ({})", RW_VERSION, GIT_SHA);
243        let listen_addr = opts.listen_addr.parse().unwrap();
244        let dashboard_addr = opts.dashboard_host.map(|x| x.parse().unwrap());
245        let prometheus_addr = opts.prometheus_listener_addr.map(|x| x.parse().unwrap());
246        let meta_store_config = config.meta.meta_store_config.clone();
247        let backend = match config.meta.backend {
248            MetaBackend::Mem => {
249                if opts.sql_endpoint.is_some() {
250                    tracing::warn!("`--sql-endpoint` is ignored when using `mem` backend");
251                }
252                MetaStoreBackend::Mem
253            }
254            MetaBackend::Sql => MetaStoreBackend::Sql {
255                endpoint: opts
256                    .sql_endpoint
257                    .expect("sql endpoint is required")
258                    .expose_secret()
259                    .clone(),
260                config: meta_store_config,
261            },
262            MetaBackend::Sqlite => MetaStoreBackend::Sql {
263                endpoint: format!(
264                    "sqlite://{}?mode=rwc",
265                    opts.sql_endpoint
266                        .expect("sql endpoint is required")
267                        .expose_secret()
268                ),
269                config: meta_store_config,
270            },
271            MetaBackend::Postgres => MetaStoreBackend::Sql {
272                endpoint: format!(
273                    "postgres://{}:{}@{}/{}{}",
274                    opts.sql_username,
275                    opts.sql_password.expose_secret(),
276                    opts.sql_endpoint
277                        .expect("sql endpoint is required")
278                        .expose_secret(),
279                    opts.sql_database,
280                    if let Some(params) = &opts.sql_url_params
281                        && !params.is_empty()
282                    {
283                        format!("?{}", params)
284                    } else {
285                        "".to_owned()
286                    }
287                ),
288                config: meta_store_config,
289            },
290            MetaBackend::Mysql => MetaStoreBackend::Sql {
291                endpoint: format!(
292                    "mysql://{}:{}@{}/{}{}",
293                    opts.sql_username,
294                    opts.sql_password.expose_secret(),
295                    opts.sql_endpoint
296                        .expect("sql endpoint is required")
297                        .expose_secret(),
298                    opts.sql_database,
299                    if let Some(params) = &opts.sql_url_params
300                        && !params.is_empty()
301                    {
302                        format!("?{}", params)
303                    } else {
304                        "".to_owned()
305                    }
306                ),
307                config: meta_store_config,
308            },
309        };
310        validate_config(&config);
311
312        let total_memory_bytes = resource_util::memory::system_memory_available_bytes();
313        let heap_profiler =
314            HeapProfiler::new(total_memory_bytes, config.server.heap_profiling.clone());
315        // Run a background heap profiler
316        heap_profiler.start();
317
318        let secret_store_private_key = opts
319            .secret_store_private_key_hex
320            .map(|key| hex::decode(key).unwrap());
321        let max_heartbeat_interval =
322            Duration::from_secs(config.meta.max_heartbeat_interval_secs as u64);
323        let max_idle_ms = config.meta.dangerous_max_idle_secs.unwrap_or(0) * 1000;
324        let in_flight_barrier_nums = config.streaming.in_flight_barrier_nums;
325        let snapshot_backfill_finish_max_lagged_barriers = config
326            .streaming
327            .snapshot_backfill_finish_max_lagged_barriers;
328        let snapshot_backfill_barrier_amplification_factor = config
329            .streaming
330            .snapshot_backfill_barrier_amplification_factor;
331        let privatelink_endpoint_default_tags =
332            opts.privatelink_endpoint_default_tags.map(|tags| {
333                tags.split(',')
334                    .map(|s| {
335                        let key_val = s.split_once('=').unwrap();
336                        (key_val.0.to_owned(), key_val.1.to_owned())
337                    })
338                    .collect()
339            });
340
341        let add_info = AddressInfo {
342            advertise_addr: opts.advertise_addr.clone(),
343            listen_addr,
344            prometheus_addr,
345            dashboard_addr,
346        };
347
348        const MIN_TIMEOUT_INTERVAL_SEC: u64 = 20;
349        let compaction_task_max_progress_interval_secs = {
350            let retry_config = &config.storage.object_store.retry;
351            let max_streaming_read_timeout_ms = (retry_config.streaming_read_attempt_timeout_ms
352                + retry_config.req_backoff_max_delay_ms)
353                * retry_config.streaming_read_retry_attempts as u64;
354            let max_streaming_upload_timeout_ms = (retry_config
355                .streaming_upload_attempt_timeout_ms
356                + retry_config.req_backoff_max_delay_ms)
357                * retry_config.streaming_upload_retry_attempts as u64;
358            let max_upload_timeout_ms = (retry_config.upload_attempt_timeout_ms
359                + retry_config.req_backoff_max_delay_ms)
360                * retry_config.upload_retry_attempts as u64;
361            let max_read_timeout_ms = (retry_config.read_attempt_timeout_ms
362                + retry_config.req_backoff_max_delay_ms)
363                * retry_config.read_retry_attempts as u64;
364            let max_timeout_ms = max_streaming_read_timeout_ms
365                .max(max_upload_timeout_ms)
366                .max(max_streaming_upload_timeout_ms)
367                .max(max_read_timeout_ms)
368                .max(config.meta.compaction_task_max_progress_interval_secs * 1000);
369            max_timeout_ms / 1000
370        } + MIN_TIMEOUT_INTERVAL_SEC;
371
372        Box::pin(rpc_serve(
373            add_info,
374            backend,
375            max_heartbeat_interval,
376            config.meta.meta_leader_lease_secs,
377            config.server.clone(),
378            MetaOpts {
379                enable_recovery: !config.meta.disable_recovery,
380                disable_automatic_parallelism_control: config
381                    .meta
382                    .disable_automatic_parallelism_control,
383                parallelism_control_batch_size: config.meta.parallelism_control_batch_size,
384                parallelism_control_trigger_period_sec: config
385                    .meta
386                    .parallelism_control_trigger_period_sec,
387                parallelism_control_trigger_first_delay_sec: config
388                    .meta
389                    .parallelism_control_trigger_first_delay_sec,
390                in_flight_barrier_nums,
391                snapshot_backfill_finish_max_lagged_barriers,
392                snapshot_backfill_barrier_amplification_factor,
393                max_idle_ms,
394                compaction_deterministic_test: config.meta.enable_compaction_deterministic,
395                default_parallelism: config.meta.default_parallelism,
396                vacuum_interval_sec: config.meta.vacuum_interval_sec,
397                time_travel_vacuum_interval_sec: config
398                    .meta
399                    .developer
400                    .time_travel_vacuum_interval_sec,
401                time_travel_vacuum_max_version_count: config
402                    .meta
403                    .developer
404                    .time_travel_vacuum_max_version_count,
405                vacuum_spin_interval_ms: config.meta.vacuum_spin_interval_ms,
406                iceberg_gc_interval_sec: config.meta.iceberg_gc_interval_sec,
407                iceberg_compaction_report_timeout_sec: config
408                    .meta
409                    .iceberg_compaction_report_timeout_sec,
410                iceberg_compaction_config_refresh_interval_sec: config
411                    .meta
412                    .iceberg_compaction_config_refresh_interval_sec,
413                hummock_version_checkpoint_interval_sec: config
414                    .meta
415                    .hummock_version_checkpoint_interval_sec,
416                enable_hummock_data_archive: config.meta.enable_hummock_data_archive,
417                checkpoint_compression_algorithm: config.meta.checkpoint_compression_algorithm,
418                checkpoint_read_chunk_size: config.meta.checkpoint_read_chunk_size,
419                checkpoint_read_max_in_flight_chunks: config
420                    .meta
421                    .checkpoint_read_max_in_flight_chunks,
422                hummock_time_travel_snapshot_interval: config
423                    .meta
424                    .hummock_time_travel_snapshot_interval,
425                hummock_time_travel_sst_info_fetch_batch_size: config
426                    .meta
427                    .developer
428                    .hummock_time_travel_sst_info_fetch_batch_size,
429                hummock_time_travel_sst_info_insert_batch_size: config
430                    .meta
431                    .developer
432                    .hummock_time_travel_sst_info_insert_batch_size,
433                hummock_time_travel_epoch_version_insert_batch_size: config
434                    .meta
435                    .developer
436                    .hummock_time_travel_epoch_version_insert_batch_size,
437                hummock_time_travel_delta_fetch_batch_size: config
438                    .meta
439                    .developer
440                    .hummock_time_travel_delta_fetch_batch_size,
441                hummock_gc_history_insert_batch_size: config
442                    .meta
443                    .developer
444                    .hummock_gc_history_insert_batch_size,
445                hummock_time_travel_filter_out_objects_batch_size: config
446                    .meta
447                    .developer
448                    .hummock_time_travel_filter_out_objects_batch_size,
449                hummock_time_travel_filter_out_objects_v1: config
450                    .meta
451                    .developer
452                    .hummock_time_travel_filter_out_objects_v1,
453                hummock_time_travel_filter_out_objects_list_version_batch_size: config
454                    .meta
455                    .developer
456                    .hummock_time_travel_filter_out_objects_list_version_batch_size,
457                hummock_time_travel_filter_out_objects_list_delta_batch_size: config
458                    .meta
459                    .developer
460                    .hummock_time_travel_filter_out_objects_list_delta_batch_size,
461                min_delta_log_num_for_hummock_version_checkpoint: config
462                    .meta
463                    .min_delta_log_num_for_hummock_version_checkpoint,
464                min_sst_retention_time_sec: config.meta.min_sst_retention_time_sec,
465                full_gc_interval_sec: config.meta.full_gc_interval_sec,
466                full_gc_object_limit: config.meta.full_gc_object_limit,
467                gc_history_retention_time_sec: config.meta.gc_history_retention_time_sec,
468                max_inflight_time_travel_query: config.meta.max_inflight_time_travel_query,
469                enable_committed_sst_sanity_check: config.meta.enable_committed_sst_sanity_check,
470                periodic_compaction_interval_sec: config.meta.periodic_compaction_interval_sec,
471                node_num_monitor_interval_sec: config.meta.node_num_monitor_interval_sec,
472                protect_drop_table_with_incoming_sink: config
473                    .meta
474                    .protect_drop_table_with_incoming_sink,
475                prometheus_endpoint: opts.prometheus_endpoint,
476                prometheus_selector: opts.prometheus_selector,
477                vpc_id: opts.vpc_id,
478                security_group_id: opts.security_group_id,
479                privatelink_endpoint_default_tags,
480                periodic_space_reclaim_compaction_interval_sec: config
481                    .meta
482                    .periodic_space_reclaim_compaction_interval_sec,
483                telemetry_enabled: config.server.telemetry_enabled,
484                periodic_ttl_reclaim_compaction_interval_sec: config
485                    .meta
486                    .periodic_ttl_reclaim_compaction_interval_sec,
487                periodic_tombstone_reclaim_compaction_interval_sec: config
488                    .meta
489                    .periodic_tombstone_reclaim_compaction_interval_sec,
490                periodic_scheduling_compaction_group_split_interval_sec: config
491                    .meta
492                    .periodic_scheduling_compaction_group_split_interval_sec,
493                enable_compaction_group_normalize: config.meta.enable_compaction_group_normalize,
494                max_normalize_splits_per_round: config.meta.max_normalize_splits_per_round,
495                periodic_scheduling_compaction_group_merge_interval_sec: config
496                    .meta
497                    .periodic_scheduling_compaction_group_merge_interval_sec,
498                compaction_group_merge_dimension_threshold: config
499                    .meta
500                    .compaction_group_merge_dimension_threshold,
501                table_high_write_throughput_threshold: config
502                    .meta
503                    .table_high_write_throughput_threshold,
504                table_low_write_throughput_threshold: config
505                    .meta
506                    .table_low_write_throughput_threshold,
507                partition_vnode_count: config.meta.partition_vnode_count,
508                compact_task_table_size_partition_threshold_low: config
509                    .meta
510                    .compact_task_table_size_partition_threshold_low,
511                compact_task_table_size_partition_threshold_high: config
512                    .meta
513                    .compact_task_table_size_partition_threshold_high,
514                do_not_config_object_storage_lifecycle: config
515                    .meta
516                    .do_not_config_object_storage_lifecycle,
517                compaction_task_max_heartbeat_interval_secs: config
518                    .meta
519                    .compaction_task_max_heartbeat_interval_secs,
520                compaction_task_max_progress_interval_secs,
521                compaction_task_id_refill_capacity: config.meta.compaction_task_id_refill_capacity,
522                compaction_config: Some(config.meta.compaction_config),
523                hybrid_partition_node_count: config.meta.hybrid_partition_vnode_count,
524                event_log_enabled: config.meta.event_log_enabled,
525                event_log_channel_max_size: config.meta.event_log_channel_max_size,
526                advertise_addr: opts.advertise_addr,
527                cached_traces_num: config.meta.developer.cached_traces_num,
528                cached_traces_memory_limit_bytes: config
529                    .meta
530                    .developer
531                    .cached_traces_memory_limit_bytes,
532                enable_trivial_move: config.meta.developer.enable_trivial_move,
533                enable_check_task_level_overlap: config
534                    .meta
535                    .developer
536                    .enable_check_task_level_overlap,
537                enable_dropped_column_reclaim: config.meta.enable_dropped_column_reclaim,
538                split_group_size_ratio: config.meta.split_group_size_ratio,
539                refresh_scheduler_interval_sec: config
540                    .streaming
541                    .developer
542                    .refresh_scheduler_interval_sec,
543                table_stat_high_write_throughput_ratio_for_split: config
544                    .meta
545                    .table_stat_high_write_throughput_ratio_for_split,
546                table_stat_low_write_throughput_ratio_for_merge: config
547                    .meta
548                    .table_stat_low_write_throughput_ratio_for_merge,
549                table_stat_throuput_window_seconds_for_split: config
550                    .meta
551                    .table_stat_throuput_window_seconds_for_split,
552                table_stat_throuput_window_seconds_for_merge: config
553                    .meta
554                    .table_stat_throuput_window_seconds_for_merge,
555                object_store_config: config.storage.object_store,
556                max_trivial_move_task_count_per_loop: config
557                    .meta
558                    .developer
559                    .max_trivial_move_task_count_per_loop,
560                max_get_task_probe_times: config.meta.developer.max_get_task_probe_times,
561                secret_store_private_key,
562                temp_secret_file_dir: opts.temp_secret_file_dir,
563                actor_cnt_per_worker_parallelism_hard_limit: config
564                    .meta
565                    .developer
566                    .actor_cnt_per_worker_parallelism_hard_limit,
567                actor_cnt_per_worker_parallelism_soft_limit: config
568                    .meta
569                    .developer
570                    .actor_cnt_per_worker_parallelism_soft_limit,
571                table_change_log_insert_batch_size: config
572                    .meta
573                    .developer
574                    .table_change_log_insert_batch_size,
575                table_change_log_delete_batch_size: config
576                    .meta
577                    .developer
578                    .table_change_log_delete_batch_size,
579                license_key_path: opts.license_key_path,
580                compute_client_config: config.meta.developer.compute_client_config.clone(),
581                stream_client_config: config.meta.developer.stream_client_config.clone(),
582                frontend_client_config: config.meta.developer.frontend_client_config.clone(),
583                redact_sql_option_keywords: Arc::new(
584                    config
585                        .batch
586                        .redact_sql_option_keywords
587                        .into_iter()
588                        .collect(),
589                ),
590                cdc_table_split_init_sleep_interval_splits: config
591                    .meta
592                    .cdc_table_split_init_sleep_interval_splits,
593                cdc_table_split_init_sleep_duration_millis: config
594                    .meta
595                    .cdc_table_split_init_sleep_duration_millis,
596                cdc_table_split_init_insert_batch_size: config
597                    .meta
598                    .cdc_table_split_init_insert_batch_size,
599
600                enable_legacy_table_migration: config.meta.enable_legacy_table_migration,
601                pause_on_next_bootstrap_offline: config.meta.pause_on_next_bootstrap_offline,
602                serverless_backfill_controller_addr: opts.serverless_backfill_controller_addr,
603            },
604            config.system.into_init_system_params(),
605            config.session_init,
606            shutdown,
607        ))
608        .await
609        .unwrap();
610    })
611}
612
613fn validate_config(config: &RwConfig) {
614    if config.meta.meta_leader_lease_secs <= 2 {
615        let error_msg = "meta leader lease secs should be larger than 2";
616        tracing::error!(error_msg);
617        panic!("{}", error_msg);
618    }
619
620    if config.meta.parallelism_control_batch_size == 0 {
621        let error_msg = "parallelism control batch size should be larger than 0";
622        tracing::error!(error_msg);
623        panic!("{}", error_msg);
624    }
625
626    if config.meta.checkpoint_read_chunk_size == 0 {
627        let error_msg = "checkpoint read chunk size should be larger than 0";
628        tracing::error!(error_msg);
629        panic!("{}", error_msg);
630    }
631
632    if config.meta.checkpoint_read_max_in_flight_chunks == 0 {
633        let error_msg = "checkpoint read max in flight chunks should be larger than 0";
634        tracing::error!(error_msg);
635        panic!("{}", error_msg);
636    }
637
638    if config.meta.compaction_task_id_refill_capacity == 0 {
639        let error_msg = "compaction task id refill capacity should be larger than 0";
640        tracing::error!(error_msg);
641        panic!("{}", error_msg);
642    }
643
644    if config.meta.iceberg_compaction_report_timeout_sec == 0 {
645        let error_msg = "iceberg compaction report timeout sec should be larger than 0";
646        tracing::error!(error_msg);
647        panic!("{}", error_msg);
648    }
649
650    if config.meta.iceberg_compaction_config_refresh_interval_sec == 0 {
651        let error_msg = "iceberg compaction config refresh interval sec should be larger than 0";
652        tracing::error!(error_msg);
653        panic!("{}", error_msg);
654    }
655}