@@ -17,6 +17,7 @@ use std::time::{Duration, Instant};
1717
1818use futures:: future:: { BoxFuture , FutureExt } ;
1919use itertools:: { Either , Itertools } ;
20+ use mz_adapter_types:: bootstrap_builtin_cluster_config:: BootstrapBuiltinClusterConfig ;
2021use mz_adapter_types:: dyncfgs:: { ENABLE_CONTINUAL_TASK_BUILTINS , ENABLE_EXPRESSION_CACHE } ;
2122use mz_catalog:: builtin:: {
2223 Builtin , Fingerprint , BUILTINS , BUILTIN_CLUSTERS , BUILTIN_CLUSTER_REPLICAS , BUILTIN_PREFIXES ,
@@ -200,22 +201,22 @@ impl Catalog {
200201 // Add any new builtin objects and remove old ones.
201202 let ( migrated_builtins, new_builtin_collections) =
202203 add_new_remove_old_builtin_items_migration ( & state. config ( ) . builtins_cfg , & mut txn) ?;
203- let cluster_sizes = BuiltinBootstrapClusterSizes {
204- system_cluster : config. builtin_system_cluster_replica_size ,
205- catalog_server_cluster : config. builtin_catalog_server_cluster_replica_size ,
206- probe_cluster : config. builtin_probe_cluster_replica_size ,
207- support_cluster : config. builtin_support_cluster_replica_size ,
208- analytics_cluster : config. builtin_analytics_cluster_replica_size ,
204+ let builtin_bootstrap_cluster_config_map = BuiltinBootstrapClusterConfigMap {
205+ system_cluster : config. builtin_system_cluster_config ,
206+ catalog_server_cluster : config. builtin_catalog_server_cluster_config ,
207+ probe_cluster : config. builtin_probe_cluster_config ,
208+ support_cluster : config. builtin_support_cluster_config ,
209+ analytics_cluster : config. builtin_analytics_cluster_config ,
209210 } ;
210211 add_new_remove_old_builtin_clusters_migration (
211212 & mut txn,
212- & cluster_sizes ,
213+ & builtin_bootstrap_cluster_config_map ,
213214 & state. cluster_replica_sizes ,
214215 ) ?;
215216 add_new_remove_old_builtin_introspection_source_migration ( & mut txn) ?;
216217 add_new_remove_old_builtin_cluster_replicas_migration (
217218 & mut txn,
218- & cluster_sizes ,
219+ & builtin_bootstrap_cluster_config_map ,
219220 & state. cluster_replica_sizes ,
220221 ) ?;
221222 add_new_remove_old_builtin_roles_migration ( & mut txn) ?;
@@ -855,7 +856,7 @@ fn add_new_remove_old_builtin_items_migration(
855856
856857fn add_new_remove_old_builtin_clusters_migration (
857858 txn : & mut mz_catalog:: durable:: Transaction < ' _ > ,
858- builtin_cluster_sizes : & BuiltinBootstrapClusterSizes ,
859+ builtin_cluster_config_map : & BuiltinBootstrapClusterConfigMap ,
859860 cluster_sizes : & ClusterReplicaSizeMap ,
860861) -> Result < ( ) , mz_catalog:: durable:: CatalogError > {
861862 let mut durable_clusters: BTreeMap < _ , _ > = txn
@@ -867,18 +868,19 @@ fn add_new_remove_old_builtin_clusters_migration(
867868 // Add new clusters.
868869 for builtin_cluster in BUILTIN_CLUSTERS {
869870 if durable_clusters. remove ( builtin_cluster. name ) . is_none ( ) {
870- let cluster_size = builtin_cluster_sizes. get_size ( builtin_cluster. name ) ?;
871- let cluster_allocation = cluster_sizes. get_allocation_by_name ( & cluster_size) ?;
871+ let cluster_config = builtin_cluster_config_map. get_config ( builtin_cluster. name ) ?;
872+ let cluster_allocation = cluster_sizes. get_allocation_by_name ( & cluster_config. size ) ?;
873+
872874 txn. insert_system_cluster (
873875 builtin_cluster. name ,
874876 vec ! [ ] ,
875877 builtin_cluster. privileges . to_vec ( ) ,
876878 builtin_cluster. owner_id . to_owned ( ) ,
877879 mz_catalog:: durable:: ClusterConfig {
878880 variant : mz_catalog:: durable:: ClusterVariant :: Managed ( ClusterVariantManaged {
879- size : cluster_size ,
881+ size : cluster_config . size ,
880882 availability_zones : vec ! [ ] ,
881- replication_factor : builtin_cluster . replication_factor ,
883+ replication_factor : cluster_config . replication_factor ,
882884 disk : cluster_allocation. is_cc ,
883885 logging : default_logging_config ( ) ,
884886 optimizer_feature_overrides : Default :: default ( ) ,
@@ -968,7 +970,7 @@ fn add_new_remove_old_builtin_roles_migration(
968970
969971fn add_new_remove_old_builtin_cluster_replicas_migration (
970972 txn : & mut Transaction < ' _ > ,
971- builtin_cluster_sizes : & BuiltinBootstrapClusterSizes ,
973+ builtin_cluster_config_map : & BuiltinBootstrapClusterConfigMap ,
972974 cluster_sizes : & ClusterReplicaSizeMap ,
973975) -> Result < ( ) , AdapterError > {
974976 let cluster_lookup: BTreeMap < _ , _ > = txn
@@ -996,12 +998,18 @@ fn add_new_remove_old_builtin_cluster_replicas_migration(
996998 let replica_names = durable_replicas
997999 . get_mut ( & cluster. id )
9981000 . unwrap_or ( & mut empty_map) ;
999- if replica_names. remove ( builtin_replica. name ) . is_none ( ) {
1001+
1002+ let builtin_cluster_boostrap_config =
1003+ builtin_cluster_config_map. get_config ( builtin_replica. cluster_name ) ?;
1004+ if replica_names. remove ( builtin_replica. name ) . is_none ( )
1005+ // NOTE(SangJunBak): We need to explicitly check the replication factor because
1006+ // BUILT_IN_CLUSTER_REPLICAS is constant throughout all deployments but the replication
1007+ // factor is configurable on bootstrap.
1008+ && builtin_cluster_boostrap_config. replication_factor > 0
1009+ {
10001010 let replica_size = match cluster. config . variant {
10011011 ClusterVariant :: Managed ( ClusterVariantManaged { ref size, .. } ) => size. clone ( ) ,
1002- ClusterVariant :: Unmanaged => {
1003- builtin_cluster_sizes. get_size ( builtin_replica. cluster_name ) ?
1004- }
1012+ ClusterVariant :: Unmanaged => builtin_cluster_boostrap_config. size ,
10051013 } ;
10061014 let replica_allocation = cluster_sizes. get_allocation_by_name ( & replica_size) ?;
10071015
@@ -1115,37 +1123,44 @@ fn default_logging_config() -> ReplicaLogging {
11151123 interval : Some ( Duration :: from_secs ( 1 ) ) ,
11161124 }
11171125}
1118- pub struct BuiltinBootstrapClusterSizes {
1119- /// Size to default system_cluster on bootstrap
1120- pub system_cluster : String ,
1121- /// Size to default catalog_server_cluster on bootstrap
1122- pub catalog_server_cluster : String ,
1123- /// Size to default probe_cluster on bootstrap
1124- pub probe_cluster : String ,
1125- /// Size to default support_cluster on bootstrap
1126- pub support_cluster : String ,
1126+
1127+ #[ derive( Debug ) ]
1128+ pub struct BuiltinBootstrapClusterConfigMap {
1129+ /// Size and replication factor to default system_cluster on bootstrap
1130+ pub system_cluster : BootstrapBuiltinClusterConfig ,
1131+ /// Size and replication factor to default catalog_server_cluster on bootstrap
1132+ pub catalog_server_cluster : BootstrapBuiltinClusterConfig ,
1133+ /// Size and replication factor to default probe_cluster on bootstrap
1134+ pub probe_cluster : BootstrapBuiltinClusterConfig ,
1135+ /// Size and replication factor to default support_cluster on bootstrap
1136+ pub support_cluster : BootstrapBuiltinClusterConfig ,
11271137 /// Size to default analytics_cluster on bootstrap
1128- pub analytics_cluster : String ,
1138+ pub analytics_cluster : BootstrapBuiltinClusterConfig ,
11291139}
11301140
1131- impl BuiltinBootstrapClusterSizes {
1141+ impl BuiltinBootstrapClusterConfigMap {
11321142 /// Gets the size of the builtin cluster based on the provided name
1133- fn get_size ( & self , cluster_name : & str ) -> Result < String , mz_catalog:: durable:: CatalogError > {
1134- if cluster_name == mz_catalog:: builtin:: MZ_SYSTEM_CLUSTER . name {
1135- Ok ( self . system_cluster . clone ( ) )
1136- } else if cluster_name == mz_catalog:: builtin:: MZ_CATALOG_SERVER_CLUSTER . name {
1137- Ok ( self . catalog_server_cluster . clone ( ) )
1138- } else if cluster_name == mz_catalog:: builtin:: MZ_PROBE_CLUSTER . name {
1139- Ok ( self . probe_cluster . clone ( ) )
1140- } else if cluster_name == mz_catalog:: builtin:: MZ_SUPPORT_CLUSTER . name {
1141- Ok ( self . support_cluster . clone ( ) )
1142- } else if cluster_name == mz_catalog:: builtin:: MZ_ANALYTICS_CLUSTER . name {
1143- Ok ( self . analytics_cluster . clone ( ) )
1144- } else {
1145- Err ( mz_catalog:: durable:: CatalogError :: Catalog (
1146- SqlCatalogError :: UnexpectedBuiltinCluster ( cluster_name. to_owned ( ) ) ,
1147- ) )
1148- }
1143+ fn get_config (
1144+ & self ,
1145+ cluster_name : & str ,
1146+ ) -> Result < BootstrapBuiltinClusterConfig , mz_catalog:: durable:: CatalogError > {
1147+ let cluster_config = match cluster_name {
1148+ name if name == mz_catalog:: builtin:: MZ_SYSTEM_CLUSTER . name => & self . system_cluster ,
1149+ name if name == mz_catalog:: builtin:: MZ_CATALOG_SERVER_CLUSTER . name => {
1150+ & self . catalog_server_cluster
1151+ }
1152+ name if name == mz_catalog:: builtin:: MZ_PROBE_CLUSTER . name => & self . probe_cluster ,
1153+ name if name == mz_catalog:: builtin:: MZ_SUPPORT_CLUSTER . name => & self . support_cluster ,
1154+ name if name == mz_catalog:: builtin:: MZ_ANALYTICS_CLUSTER . name => {
1155+ & self . analytics_cluster
1156+ }
1157+ _ => {
1158+ return Err ( mz_catalog:: durable:: CatalogError :: Catalog (
1159+ SqlCatalogError :: UnexpectedBuiltinCluster ( cluster_name. to_owned ( ) ) ,
1160+ ) )
1161+ }
1162+ } ;
1163+ Ok ( cluster_config. clone ( ) )
11491164 }
11501165}
11511166
0 commit comments