@@ -1107,14 +1107,23 @@ collect_payloads(Props, Acc0) when is_map(Props) andalso is_list(Acc0) ->
11071107 Acc
11081108 end , Acc0 , Props ).
11091109
1110- -spec unregister_all_projections () -> Ret when
1110+ -spec unregister_legacy_projections () -> Ret when
11111111 Ret :: ok | timeout_error ().
1112+ % % @doc Unregisters any projections which were registered in RabbitMQ 3.13.x
1113+ % % versions.
1114+ % %
1115+ % % In 3.13.x until 3.13.8 we mistakenly registered these projections even if
1116+ % % Khepri was not enabled. This function is used by the `khepri_db' enable
1117+ % % callback to remove those projections before we register the ones necessary
1118+ % % for 4.0.x.
1119+ % %
1120+ % % @private
11121121
1113- unregister_all_projections () ->
1122+ unregister_legacy_projections () ->
11141123 % % Note that we don't use `all' since `khepri_mnesia_migration' also
11151124 % % creates a projection table which we don't want to unregister. Instead
1116- % % we list all of the currently used projection names:
1117- Names = [
1125+ % % we list all of the legacy projection names:
1126+ LegacyNames = [
11181127 rabbit_khepri_exchange ,
11191128 rabbit_khepri_queue ,
11201129 rabbit_khepri_vhost ,
@@ -1126,7 +1135,7 @@ unregister_all_projections() ->
11261135 rabbit_khepri_index_route ,
11271136 rabbit_khepri_topic_trie
11281137 ],
1129- khepri :unregister_projections (? STORE_ID , Names ).
1138+ khepri :unregister_projections (? STORE_ID , LegacyNames ).
11301139
11311140register_projections () ->
11321141 RegFuns = [fun register_rabbit_exchange_projection /0 ,
@@ -1181,21 +1190,21 @@ register_rabbit_vhost_projection() ->
11811190 register_simple_projection (Name , PathPattern , KeyPos ).
11821191
11831192register_rabbit_users_projection () ->
1184- Name = rabbit_khepri_users ,
1193+ Name = rabbit_khepri_user ,
11851194 PathPattern = rabbit_db_user :khepri_user_path (
11861195 _UserName = ? KHEPRI_WILDCARD_STAR ),
11871196 KeyPos = 2 , % % #internal_user.username
11881197 register_simple_projection (Name , PathPattern , KeyPos ).
11891198
11901199register_rabbit_global_runtime_parameters_projection () ->
1191- Name = rabbit_khepri_global_rtparams ,
1200+ Name = rabbit_khepri_global_rtparam ,
11921201 PathPattern = rabbit_db_rtparams :khepri_global_rp_path (
11931202 _Key = ? KHEPRI_WILDCARD_STAR_STAR ),
11941203 KeyPos = # runtime_parameters .key ,
11951204 register_simple_projection (Name , PathPattern , KeyPos ).
11961205
11971206register_rabbit_per_vhost_runtime_parameters_projection () ->
1198- Name = rabbit_khepri_per_vhost_rtparams ,
1207+ Name = rabbit_khepri_per_vhost_rtparam ,
11991208 PathPattern = rabbit_db_rtparams :khepri_vhost_rp_path (
12001209 _VHost = ? KHEPRI_WILDCARD_STAR_STAR ,
12011210 _Component = ? KHEPRI_WILDCARD_STAR_STAR ,
@@ -1204,7 +1213,7 @@ register_rabbit_per_vhost_runtime_parameters_projection() ->
12041213 register_simple_projection (Name , PathPattern , KeyPos ).
12051214
12061215register_rabbit_user_permissions_projection () ->
1207- Name = rabbit_khepri_user_permissions ,
1216+ Name = rabbit_khepri_user_permission ,
12081217 PathPattern = rabbit_db_user :khepri_user_permission_path (
12091218 _UserName = ? KHEPRI_WILDCARD_STAR ,
12101219 _VHost = ? KHEPRI_WILDCARD_STAR ),
@@ -1223,7 +1232,7 @@ register_rabbit_bindings_projection() ->
12231232 ProjectionFun = projection_fun_for_sets (MapFun ),
12241233 Options = #{keypos => # route .binding },
12251234 Projection = khepri_projection :new (
1226- rabbit_khepri_bindings , ProjectionFun , Options ),
1235+ rabbit_khepri_binding , ProjectionFun , Options ),
12271236 PathPattern = rabbit_db_binding :khepri_route_path (
12281237 _VHost = ? KHEPRI_WILDCARD_STAR ,
12291238 _ExchangeName = ? KHEPRI_WILDCARD_STAR ,
@@ -1543,7 +1552,7 @@ get_feature_state(Node) ->
15431552khepri_db_migration_enable (#{feature_name := FeatureName }) ->
15441553 maybe
15451554 ok ?= sync_cluster_membership_from_mnesia (FeatureName ),
1546- ok ?= unregister_all_projections (),
1555+ ok ?= unregister_legacy_projections (),
15471556 ok ?= register_projections (),
15481557 migrate_mnesia_tables (FeatureName )
15491558 end .
0 commit comments