risingwave_meta/manager/
env.rs

1// Copyright 2022 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 std::ops::Deref;
16use std::path::PathBuf;
17use std::sync::Arc;
18use std::sync::atomic::AtomicU32;
19
20use anyhow::Context;
21use risingwave_common::config::{
22    CompactionConfig, DefaultParallelism, ObjectStoreConfig, RpcClientConfig,
23};
24use risingwave_common::session_config::SessionConfig;
25use risingwave_common::system_param::reader::SystemParamsReader;
26use risingwave_common::{bail, system_param};
27use risingwave_meta_model::prelude::Cluster;
28use risingwave_pb::meta::SystemParams;
29use risingwave_rpc_client::{
30    FrontendClientPool, FrontendClientPoolRef, StreamClientPool, StreamClientPoolRef,
31};
32use risingwave_sqlparser::ast::RedactSqlOptionKeywordsRef;
33use sea_orm::EntityTrait;
34
35use crate::MetaResult;
36use crate::barrier::SharedActorInfos;
37use crate::controller::SqlMetaStore;
38use crate::controller::id::{
39    IdGeneratorManager as SqlIdGeneratorManager, IdGeneratorManagerRef as SqlIdGeneratorManagerRef,
40};
41use crate::controller::session_params::{SessionParamsController, SessionParamsControllerRef};
42use crate::controller::system_param::{SystemParamsController, SystemParamsControllerRef};
43use crate::hummock::sequence::SequenceGenerator;
44use crate::manager::event_log::{EventLogManagerRef, start_event_log_manager};
45use crate::manager::{IdleManager, IdleManagerRef, NotificationManager, NotificationManagerRef};
46use crate::model::ClusterId;
47
48/// [`MetaSrvEnv`] is the global environment in Meta service. The instance will be shared by all
49/// kind of managers inside Meta.
50#[derive(Clone)]
51pub struct MetaSrvEnv {
52    /// id generator manager.
53    id_gen_manager_impl: SqlIdGeneratorManagerRef,
54
55    /// system param manager.
56    system_param_manager_impl: SystemParamsControllerRef,
57
58    /// session param manager.
59    session_param_manager_impl: SessionParamsControllerRef,
60
61    /// meta store.
62    meta_store_impl: SqlMetaStore,
63
64    /// notification manager.
65    notification_manager: NotificationManagerRef,
66
67    pub shared_actor_info: SharedActorInfos,
68
69    /// stream client pool memorization.
70    stream_client_pool: StreamClientPoolRef,
71
72    /// rpc client pool for frontend nodes.
73    frontend_client_pool: FrontendClientPoolRef,
74
75    /// idle status manager.
76    idle_manager: IdleManagerRef,
77
78    event_log_manager: EventLogManagerRef,
79
80    /// Unique identifier of the cluster.
81    cluster_id: ClusterId,
82
83    pub hummock_seq: Arc<SequenceGenerator>,
84
85    /// The await-tree registry of the current meta node.
86    await_tree_reg: await_tree::Registry,
87
88    /// options read by all services
89    pub opts: Arc<MetaOpts>,
90
91    actor_id_generator: Arc<AtomicU32>,
92}
93
94/// Options shared by all meta service instances
95#[derive(Clone, serde::Serialize)]
96pub struct MetaOpts {
97    /// Whether to enable the recovery of the cluster. If disabled, the meta service will exit on
98    /// abnormal cases.
99    pub enable_recovery: bool,
100    /// Whether to disable the auto-scaling feature.
101    pub disable_automatic_parallelism_control: bool,
102    /// The number of streaming jobs per scaling operation.
103    pub parallelism_control_batch_size: usize,
104    /// The period of parallelism control trigger.
105    pub parallelism_control_trigger_period_sec: u64,
106    /// The first delay of parallelism control.
107    pub parallelism_control_trigger_first_delay_sec: u64,
108    /// The maximum number of barriers in-flight in the compute nodes.
109    pub in_flight_barrier_nums: usize,
110    /// After specified seconds of idle (no mview or flush), the process will be exited.
111    /// 0 for infinite, process will never be exited due to long idle time.
112    pub max_idle_ms: u64,
113    /// Whether run in compaction detection test mode
114    pub compaction_deterministic_test: bool,
115    /// Default parallelism of units for all streaming jobs.
116    pub default_parallelism: DefaultParallelism,
117
118    /// Interval of invoking a vacuum job, to remove stale metadata from meta store and objects
119    /// from object store.
120    pub vacuum_interval_sec: u64,
121    /// The spin interval inside a vacuum job. It avoids the vacuum job monopolizing resources of
122    /// meta node.
123    pub vacuum_spin_interval_ms: u64,
124    /// Interval of invoking iceberg garbage collection, to expire old snapshots.
125    pub iceberg_gc_interval_sec: u64,
126    pub time_travel_vacuum_interval_sec: u64,
127    pub time_travel_vacuum_max_version_count: Option<u32>,
128    /// Interval of hummock version checkpoint.
129    pub hummock_version_checkpoint_interval_sec: u64,
130    pub enable_hummock_data_archive: bool,
131    /// Compression algorithm for hummock version checkpoint: "zstd", "lz4", or "none".
132    pub checkpoint_compression_algorithm: risingwave_common::config::CheckpointCompression,
133    /// Chunk size in bytes for reading large checkpoints.
134    pub checkpoint_read_chunk_size: usize,
135    /// Maximum number of concurrent chunk reads for large checkpoints.
136    pub checkpoint_read_max_in_flight_chunks: usize,
137    pub hummock_time_travel_snapshot_interval: u64,
138    pub hummock_time_travel_sst_info_fetch_batch_size: usize,
139    pub hummock_time_travel_sst_info_insert_batch_size: usize,
140    pub hummock_time_travel_epoch_version_insert_batch_size: usize,
141    pub hummock_gc_history_insert_batch_size: usize,
142    pub hummock_time_travel_filter_out_objects_batch_size: usize,
143    pub hummock_time_travel_filter_out_objects_v1: bool,
144    pub hummock_time_travel_filter_out_objects_list_version_batch_size: usize,
145    pub hummock_time_travel_filter_out_objects_list_delta_batch_size: usize,
146    /// The minimum delta log number a new checkpoint should compact, otherwise the checkpoint
147    /// attempt is rejected. Greater value reduces object store IO, meanwhile it results in
148    /// more loss of in memory `HummockVersionCheckpoint::stale_objects` state when meta node is
149    /// restarted.
150    pub min_delta_log_num_for_hummock_version_checkpoint: u64,
151    /// Objects within `min_sst_retention_time_sec` won't be deleted by hummock full GC, even they
152    /// are dangling.
153    pub min_sst_retention_time_sec: u64,
154    /// Interval of automatic hummock full GC.
155    pub full_gc_interval_sec: u64,
156    /// Max number of object per full GC job can fetch.
157    pub full_gc_object_limit: u64,
158    /// Duration in seconds to retain garbage collection history data.
159    pub gc_history_retention_time_sec: u64,
160    /// Max number of inflight time travel query.
161    pub max_inflight_time_travel_query: u64,
162    /// Enable sanity check when SSTs are committed
163    pub enable_committed_sst_sanity_check: bool,
164    /// Schedule compaction for all compaction groups with this interval.
165    pub periodic_compaction_interval_sec: u64,
166    /// Interval of reporting the number of nodes in the cluster.
167    pub node_num_monitor_interval_sec: u64,
168    /// Whether to protect the drop table operation with incoming sink.
169    pub protect_drop_table_with_incoming_sink: bool,
170    /// The Prometheus endpoint for Meta Dashboard Service.
171    /// The Dashboard service uses this in the following ways:
172    /// 1. Query Prometheus for relevant metrics to find Stream Graph Bottleneck, and display it.
173    /// 2. Provide cluster diagnostics, at `/api/monitor/diagnose` to troubleshoot cluster.
174    ///    These are just examples which show how the Meta Dashboard Service queries Prometheus.
175    pub prometheus_endpoint: Option<String>,
176
177    /// The additional selector used when querying Prometheus.
178    pub prometheus_selector: Option<String>,
179
180    /// The VPC id of the cluster.
181    pub vpc_id: Option<String>,
182
183    /// A usable security group id to assign to a vpc endpoint
184    pub security_group_id: Option<String>,
185
186    /// Default tag for the endpoint created when creating a privatelink connection.
187    /// Will be appended to the tags specified in the `tags` field in with clause in `create
188    /// connection`.
189    pub privatelink_endpoint_default_tags: Option<Vec<(String, String)>>,
190
191    /// Schedule `space_reclaim_compaction` for all compaction groups with this interval.
192    pub periodic_space_reclaim_compaction_interval_sec: u64,
193
194    /// telemetry enabled in config file or not
195    pub telemetry_enabled: bool,
196    /// Schedule `ttl_reclaim_compaction` for all compaction groups with this interval.
197    pub periodic_ttl_reclaim_compaction_interval_sec: u64,
198
199    /// Schedule `tombstone_reclaim_compaction` for all compaction groups with this interval.
200    pub periodic_tombstone_reclaim_compaction_interval_sec: u64,
201
202    /// Schedule `periodic_scheduling_compaction_group_split_interval_sec` for all compaction groups with this interval.
203    pub periodic_scheduling_compaction_group_split_interval_sec: u64,
204
205    /// Whether config object storage bucket lifecycle to purge stale data.
206    pub do_not_config_object_storage_lifecycle: bool,
207
208    pub partition_vnode_count: u32,
209
210    /// threshold of high write throughput of state-table, unit: B/sec
211    pub table_high_write_throughput_threshold: u64,
212    /// threshold of low write throughput of state-table, unit: B/sec
213    pub table_low_write_throughput_threshold: u64,
214
215    pub compaction_task_max_heartbeat_interval_secs: u64,
216    pub compaction_task_max_progress_interval_secs: u64,
217    pub compaction_config: Option<CompactionConfig>,
218
219    /// hybrid compaction group config
220    ///
221    /// `hybrid_partition_vnode_count` determines the granularity of vnodes in the hybrid compaction group for SST alignment.
222    /// When `hybrid_partition_vnode_count` > 0, in hybrid compaction group
223    /// - Tables with high write throughput will be split at vnode granularity
224    /// - Tables with high size tables will be split by table granularity
225    ///   When `hybrid_partition_vnode_count` = 0,no longer be special alignment operations for the hybrid compaction group
226    pub hybrid_partition_node_count: u32,
227
228    pub event_log_enabled: bool,
229    pub event_log_channel_max_size: u32,
230    pub advertise_addr: String,
231    /// The number of traces to be cached in-memory by the tracing collector
232    /// embedded in the meta node.
233    pub cached_traces_num: u32,
234    /// The maximum memory usage in bytes for the tracing collector embedded
235    /// in the meta node.
236    pub cached_traces_memory_limit_bytes: usize,
237
238    /// l0 picker whether to select trivial move task
239    pub enable_trivial_move: bool,
240
241    /// l0 multi level picker whether to check the overlap accuracy between sub levels
242    pub enable_check_task_level_overlap: bool,
243    pub enable_dropped_column_reclaim: bool,
244
245    /// Whether to split the compaction group when the size of the group exceeds the threshold.
246    pub split_group_size_ratio: f64,
247
248    /// The interval in seconds for the refresh scheduler to check and trigger scheduled refreshes.
249    pub refresh_scheduler_interval_sec: u64,
250
251    /// To split the compaction group when the high throughput statistics of the group exceeds the threshold.
252    pub table_stat_high_write_throughput_ratio_for_split: f64,
253
254    /// To merge the compaction group when the low throughput statistics of the group exceeds the threshold.
255    pub table_stat_low_write_throughput_ratio_for_merge: f64,
256
257    /// The window seconds of table throughput statistic history for split compaction group.
258    pub table_stat_throuput_window_seconds_for_split: usize,
259
260    /// The window seconds of table throughput statistic history for merge compaction group.
261    pub table_stat_throuput_window_seconds_for_merge: usize,
262
263    /// The configuration of the object store
264    pub object_store_config: ObjectStoreConfig,
265
266    /// The maximum number of trivial move tasks to be picked in a single loop
267    pub max_trivial_move_task_count_per_loop: usize,
268
269    /// The maximum number of times to probe for `PullTaskEvent`
270    pub max_get_task_probe_times: usize,
271
272    pub compact_task_table_size_partition_threshold_low: u64,
273    pub compact_task_table_size_partition_threshold_high: u64,
274
275    pub periodic_scheduling_compaction_group_merge_interval_sec: u64,
276
277    pub compaction_group_merge_dimension_threshold: f64,
278
279    // The private key for the secret store, used when the secret is stored in the meta.
280    pub secret_store_private_key: Option<Vec<u8>>,
281    /// The path of the temp secret file directory.
282    pub temp_secret_file_dir: String,
283
284    // Cluster limits
285    pub actor_cnt_per_worker_parallelism_hard_limit: usize,
286    pub actor_cnt_per_worker_parallelism_soft_limit: usize,
287
288    pub license_key_path: Option<PathBuf>,
289
290    pub compute_client_config: RpcClientConfig,
291    pub stream_client_config: RpcClientConfig,
292    pub frontend_client_config: RpcClientConfig,
293    pub redact_sql_option_keywords: RedactSqlOptionKeywordsRef,
294
295    pub cdc_table_split_init_sleep_interval_splits: u64,
296    pub cdc_table_split_init_sleep_duration_millis: u64,
297    pub cdc_table_split_init_insert_batch_size: u64,
298
299    pub enable_legacy_table_migration: bool,
300    pub pause_on_next_bootstrap_offline: bool,
301}
302
303impl MetaOpts {
304    /// Default opts for testing. Some tests need `enable_recovery=true`
305    pub fn test(enable_recovery: bool) -> Self {
306        Self {
307            enable_recovery,
308            disable_automatic_parallelism_control: false,
309            parallelism_control_batch_size: 1,
310            parallelism_control_trigger_period_sec: 10,
311            parallelism_control_trigger_first_delay_sec: 30,
312            in_flight_barrier_nums: 40,
313            max_idle_ms: 0,
314            compaction_deterministic_test: false,
315            default_parallelism: DefaultParallelism::Full,
316            vacuum_interval_sec: 30,
317            time_travel_vacuum_interval_sec: 30,
318            time_travel_vacuum_max_version_count: None,
319            vacuum_spin_interval_ms: 0,
320            iceberg_gc_interval_sec: 3600,
321            hummock_version_checkpoint_interval_sec: 30,
322            enable_hummock_data_archive: false,
323            checkpoint_compression_algorithm:
324                risingwave_common::config::CheckpointCompression::Zstd,
325            checkpoint_read_chunk_size: 128 * 1024 * 1024,
326            checkpoint_read_max_in_flight_chunks: 4,
327            hummock_time_travel_snapshot_interval: 0,
328            hummock_time_travel_sst_info_fetch_batch_size: 10_000,
329            hummock_time_travel_sst_info_insert_batch_size: 10,
330            hummock_time_travel_epoch_version_insert_batch_size: 1000,
331            hummock_gc_history_insert_batch_size: 1000,
332            hummock_time_travel_filter_out_objects_batch_size: 1000,
333            hummock_time_travel_filter_out_objects_v1: false,
334            hummock_time_travel_filter_out_objects_list_version_batch_size: 10,
335            hummock_time_travel_filter_out_objects_list_delta_batch_size: 1000,
336            min_delta_log_num_for_hummock_version_checkpoint: 1,
337            min_sst_retention_time_sec: 3600 * 24 * 7,
338            full_gc_interval_sec: 3600 * 24 * 7,
339            full_gc_object_limit: 100_000,
340            gc_history_retention_time_sec: 3600 * 24 * 7,
341            max_inflight_time_travel_query: 1000,
342            enable_committed_sst_sanity_check: false,
343            periodic_compaction_interval_sec: 300,
344            node_num_monitor_interval_sec: 10,
345            protect_drop_table_with_incoming_sink: false,
346            prometheus_endpoint: None,
347            prometheus_selector: None,
348            vpc_id: None,
349            security_group_id: None,
350            privatelink_endpoint_default_tags: None,
351            periodic_space_reclaim_compaction_interval_sec: 60,
352            telemetry_enabled: false,
353            periodic_ttl_reclaim_compaction_interval_sec: 60,
354            periodic_tombstone_reclaim_compaction_interval_sec: 60,
355            periodic_scheduling_compaction_group_split_interval_sec: 60,
356            compact_task_table_size_partition_threshold_low: 128 * 1024 * 1024,
357            compact_task_table_size_partition_threshold_high: 512 * 1024 * 1024,
358            table_high_write_throughput_threshold: 128 * 1024 * 1024,
359            table_low_write_throughput_threshold: 64 * 1024 * 1024,
360            do_not_config_object_storage_lifecycle: true,
361            partition_vnode_count: 32,
362            compaction_task_max_heartbeat_interval_secs: 0,
363            compaction_task_max_progress_interval_secs: 1,
364            compaction_config: None,
365            hybrid_partition_node_count: 4,
366            event_log_enabled: false,
367            event_log_channel_max_size: 1,
368            advertise_addr: "".to_owned(),
369            cached_traces_num: 1,
370            cached_traces_memory_limit_bytes: usize::MAX,
371            enable_trivial_move: true,
372            enable_check_task_level_overlap: true,
373            enable_dropped_column_reclaim: false,
374            object_store_config: ObjectStoreConfig::default(),
375            max_trivial_move_task_count_per_loop: 256,
376            max_get_task_probe_times: 5,
377            secret_store_private_key: Some(
378                hex::decode("0123456789abcdef0123456789abcdef").unwrap(),
379            ),
380            temp_secret_file_dir: "./secrets".to_owned(),
381            actor_cnt_per_worker_parallelism_hard_limit: usize::MAX,
382            actor_cnt_per_worker_parallelism_soft_limit: usize::MAX,
383            split_group_size_ratio: 0.9,
384            table_stat_high_write_throughput_ratio_for_split: 0.5,
385            table_stat_low_write_throughput_ratio_for_merge: 0.7,
386            table_stat_throuput_window_seconds_for_split: 60,
387            table_stat_throuput_window_seconds_for_merge: 240,
388            periodic_scheduling_compaction_group_merge_interval_sec: 60 * 10,
389            compaction_group_merge_dimension_threshold: 1.2,
390            license_key_path: None,
391            compute_client_config: RpcClientConfig::default(),
392            stream_client_config: RpcClientConfig::default(),
393            frontend_client_config: RpcClientConfig::default(),
394            redact_sql_option_keywords: Arc::new(Default::default()),
395            cdc_table_split_init_sleep_interval_splits: 1000,
396            cdc_table_split_init_sleep_duration_millis: 10,
397            cdc_table_split_init_insert_batch_size: 1000,
398            enable_legacy_table_migration: true,
399            refresh_scheduler_interval_sec: 60,
400            pause_on_next_bootstrap_offline: false,
401        }
402    }
403}
404
405impl MetaSrvEnv {
406    pub async fn new(
407        opts: MetaOpts,
408        mut init_system_params: SystemParams,
409        init_session_config: SessionConfig,
410        meta_store_impl: SqlMetaStore,
411    ) -> MetaResult<Self> {
412        let idle_manager = Arc::new(IdleManager::new(opts.max_idle_ms));
413        let stream_client_pool =
414            Arc::new(StreamClientPool::new(1, opts.stream_client_config.clone())); // typically no need for plural clients
415        let frontend_client_pool = Arc::new(FrontendClientPool::new(
416            1,
417            opts.frontend_client_config.clone(),
418        ));
419        let event_log_manager = Arc::new(start_event_log_manager(
420            opts.event_log_enabled,
421            opts.event_log_channel_max_size,
422        ));
423
424        // When license key path is specified, license key from system parameters can be easily
425        // overwritten. So we simply reject this case.
426        if opts.license_key_path.is_some()
427            && init_system_params.license_key
428                != system_param::default::license_key_opt().map(Into::into)
429        {
430            bail!(
431                "argument `--license-key-path` (or env var `RW_LICENSE_KEY_PATH`) and \
432                 system parameter `license_key` (or env var `RW_LICENSE_KEY`) may not \
433                 be set at the same time"
434            );
435        }
436
437        let cluster_first_launch = meta_store_impl.up().await.context(
438            "Failed to initialize the meta store, \
439            this may happen if there's existing metadata incompatible with the current version of RisingWave, \
440            e.g., downgrading from a newer release or a nightly build to an older one. \
441            For a single-node deployment, you may want to reset all data by deleting the data directory, \
442            typically located at `~/.risingwave`.",
443        )?;
444
445        let notification_manager =
446            Arc::new(NotificationManager::new(meta_store_impl.clone()).await);
447        let cluster_id = Cluster::find()
448            .one(&meta_store_impl.conn)
449            .await?
450            .map(|c| c.cluster_id.to_string().into())
451            .unwrap();
452
453        // For new clusters:
454        // - the name of the object store needs to be prefixed according to the object id.
455        //
456        // For old clusters
457        // - the prefix is ​​not divided for the sake of compatibility.
458        init_system_params.use_new_object_prefix_strategy = Some(cluster_first_launch);
459
460        let system_param_controller = Arc::new(
461            SystemParamsController::new(
462                meta_store_impl.clone(),
463                notification_manager.clone(),
464                init_system_params,
465            )
466            .await?,
467        );
468        let session_param_controller = Arc::new(
469            SessionParamsController::new(
470                meta_store_impl.clone(),
471                notification_manager.clone(),
472                init_session_config,
473            )
474            .await?,
475        );
476        Ok(Self {
477            id_gen_manager_impl: Arc::new(SqlIdGeneratorManager::new(&meta_store_impl.conn).await?),
478            system_param_manager_impl: system_param_controller,
479            session_param_manager_impl: session_param_controller,
480            meta_store_impl: meta_store_impl.clone(),
481            shared_actor_info: SharedActorInfos::new(notification_manager.clone()),
482            notification_manager,
483            stream_client_pool,
484            frontend_client_pool,
485            idle_manager,
486            event_log_manager,
487            cluster_id,
488            hummock_seq: Arc::new(SequenceGenerator::new(meta_store_impl.conn.clone())),
489            opts: opts.into(),
490            // Await trees on the meta node is lightweight, thus always enabled.
491            await_tree_reg: await_tree::Registry::new(Default::default()),
492            actor_id_generator: Arc::new(AtomicU32::new(0)),
493        })
494    }
495
496    pub fn meta_store(&self) -> SqlMetaStore {
497        self.meta_store_impl.clone()
498    }
499
500    pub fn meta_store_ref(&self) -> &SqlMetaStore {
501        &self.meta_store_impl
502    }
503
504    pub fn id_gen_manager(&self) -> &SqlIdGeneratorManagerRef {
505        &self.id_gen_manager_impl
506    }
507
508    pub fn notification_manager_ref(&self) -> NotificationManagerRef {
509        self.notification_manager.clone()
510    }
511
512    pub fn notification_manager(&self) -> &NotificationManager {
513        self.notification_manager.deref()
514    }
515
516    pub fn idle_manager_ref(&self) -> IdleManagerRef {
517        self.idle_manager.clone()
518    }
519
520    pub fn idle_manager(&self) -> &IdleManager {
521        self.idle_manager.deref()
522    }
523
524    pub fn actor_id_generator(&self) -> &AtomicU32 {
525        self.actor_id_generator.deref()
526    }
527
528    pub async fn system_params_reader(&self) -> SystemParamsReader {
529        self.system_param_manager_impl.get_params().await
530    }
531
532    pub fn system_params_manager_impl_ref(&self) -> SystemParamsControllerRef {
533        self.system_param_manager_impl.clone()
534    }
535
536    pub fn session_params_manager_impl_ref(&self) -> SessionParamsControllerRef {
537        self.session_param_manager_impl.clone()
538    }
539
540    pub fn stream_client_pool_ref(&self) -> StreamClientPoolRef {
541        self.stream_client_pool.clone()
542    }
543
544    pub fn stream_client_pool(&self) -> &StreamClientPool {
545        self.stream_client_pool.deref()
546    }
547
548    pub fn frontend_client_pool(&self) -> &FrontendClientPool {
549        self.frontend_client_pool.deref()
550    }
551
552    pub fn cluster_id(&self) -> &ClusterId {
553        &self.cluster_id
554    }
555
556    pub fn event_log_manager_ref(&self) -> EventLogManagerRef {
557        self.event_log_manager.clone()
558    }
559
560    pub fn await_tree_reg(&self) -> &await_tree::Registry {
561        &self.await_tree_reg
562    }
563
564    pub fn shared_actor_infos(&self) -> &SharedActorInfos {
565        &self.shared_actor_info
566    }
567}
568
569#[cfg(any(test, feature = "test"))]
570impl MetaSrvEnv {
571    // Instance for test.
572    pub async fn for_test() -> Self {
573        Self::for_test_opts(MetaOpts::test(false), |_| ()).await
574    }
575
576    pub async fn for_test_opts(
577        opts: MetaOpts,
578        on_test_system_params: impl FnOnce(&mut risingwave_pb::meta::PbSystemParams),
579    ) -> Self {
580        let mut system_params = risingwave_common::system_param::system_params_for_test();
581        on_test_system_params(&mut system_params);
582        Self::new(
583            opts,
584            system_params,
585            Default::default(),
586            SqlMetaStore::for_test().await,
587        )
588        .await
589        .unwrap()
590    }
591}