Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/rabbit/src/rabbit_db_binding.erl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
-define(MNESIA_SEMI_DURABLE_TABLE, rabbit_semi_durable_route).
-define(MNESIA_REVERSE_TABLE, rabbit_reverse_route).
-define(MNESIA_INDEX_TABLE, rabbit_index_route).
-define(KHEPRI_BINDINGS_PROJECTION, rabbit_khepri_bindings).
-define(KHEPRI_BINDINGS_PROJECTION, rabbit_khepri_binding).
-define(KHEPRI_INDEX_ROUTE_PROJECTION, rabbit_khepri_index_route).

%% -------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions deps/rabbit/src/rabbit_db_rtparams.erl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
]).

-define(MNESIA_TABLE, rabbit_runtime_parameters).
-define(KHEPRI_GLOBAL_PROJECTION, rabbit_khepri_global_rtparams).
-define(KHEPRI_VHOST_PROJECTION, rabbit_khepri_per_vhost_rtparams).
-define(KHEPRI_GLOBAL_PROJECTION, rabbit_khepri_global_rtparam).
-define(KHEPRI_VHOST_PROJECTION, rabbit_khepri_per_vhost_rtparam).
-define(any(Value), case Value of
'_' -> ?KHEPRI_WILDCARD_STAR;
_ -> Value
Expand Down
4 changes: 2 additions & 2 deletions deps/rabbit/src/rabbit_db_user.erl
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
-define(MNESIA_TABLE, rabbit_user).
-define(PERM_MNESIA_TABLE, rabbit_user_permission).
-define(TOPIC_PERM_MNESIA_TABLE, rabbit_topic_permission).
-define(KHEPRI_USERS_PROJECTION, rabbit_khepri_users).
-define(KHEPRI_PERMISSIONS_PROJECTION, rabbit_khepri_user_permissions).
-define(KHEPRI_USERS_PROJECTION, rabbit_khepri_user).
-define(KHEPRI_PERMISSIONS_PROJECTION, rabbit_khepri_user_permission).

%% -------------------------------------------------------------------
%% create().
Expand Down
31 changes: 20 additions & 11 deletions deps/rabbit/src/rabbit_khepri.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1107,14 +1107,23 @@ collect_payloads(Props, Acc0) when is_map(Props) andalso is_list(Acc0) ->
Acc
end, Acc0, Props).

-spec unregister_all_projections() -> Ret when
-spec unregister_legacy_projections() -> Ret when
Ret :: ok | timeout_error().
%% @doc Unregisters any projections which were registered in RabbitMQ 3.13.x
%% versions.
%%
%% In 3.13.x until 3.13.8 we mistakenly registered these projections even if
%% Khepri was not enabled. This function is used by the `khepri_db' enable
%% callback to remove those projections before we register the ones necessary
%% for 4.0.x.
%%
%% @private

unregister_all_projections() ->
unregister_legacy_projections() ->
%% Note that we don't use `all' since `khepri_mnesia_migration' also
%% creates a projection table which we don't want to unregister. Instead
%% we list all of the currently used projection names:
Names = [
%% we list all of the legacy projection names:
LegacyNames = [
rabbit_khepri_exchange,
rabbit_khepri_queue,
rabbit_khepri_vhost,
Expand All @@ -1126,7 +1135,7 @@ unregister_all_projections() ->
rabbit_khepri_index_route,
rabbit_khepri_topic_trie
],
khepri:unregister_projections(?STORE_ID, Names).
khepri:unregister_projections(?STORE_ID, LegacyNames).

register_projections() ->
RegFuns = [fun register_rabbit_exchange_projection/0,
Expand Down Expand Up @@ -1181,21 +1190,21 @@ register_rabbit_vhost_projection() ->
register_simple_projection(Name, PathPattern, KeyPos).

register_rabbit_users_projection() ->
Name = rabbit_khepri_users,
Name = rabbit_khepri_user,
PathPattern = rabbit_db_user:khepri_user_path(
_UserName = ?KHEPRI_WILDCARD_STAR),
KeyPos = 2, %% #internal_user.username
register_simple_projection(Name, PathPattern, KeyPos).

register_rabbit_global_runtime_parameters_projection() ->
Name = rabbit_khepri_global_rtparams,
Name = rabbit_khepri_global_rtparam,
PathPattern = rabbit_db_rtparams:khepri_global_rp_path(
_Key = ?KHEPRI_WILDCARD_STAR_STAR),
KeyPos = #runtime_parameters.key,
register_simple_projection(Name, PathPattern, KeyPos).

register_rabbit_per_vhost_runtime_parameters_projection() ->
Name = rabbit_khepri_per_vhost_rtparams,
Name = rabbit_khepri_per_vhost_rtparam,
PathPattern = rabbit_db_rtparams:khepri_vhost_rp_path(
_VHost = ?KHEPRI_WILDCARD_STAR_STAR,
_Component = ?KHEPRI_WILDCARD_STAR_STAR,
Expand All @@ -1204,7 +1213,7 @@ register_rabbit_per_vhost_runtime_parameters_projection() ->
register_simple_projection(Name, PathPattern, KeyPos).

register_rabbit_user_permissions_projection() ->
Name = rabbit_khepri_user_permissions,
Name = rabbit_khepri_user_permission,
PathPattern = rabbit_db_user:khepri_user_permission_path(
_UserName = ?KHEPRI_WILDCARD_STAR,
_VHost = ?KHEPRI_WILDCARD_STAR),
Expand All @@ -1223,7 +1232,7 @@ register_rabbit_bindings_projection() ->
ProjectionFun = projection_fun_for_sets(MapFun),
Options = #{keypos => #route.binding},
Projection = khepri_projection:new(
rabbit_khepri_bindings, ProjectionFun, Options),
rabbit_khepri_binding, ProjectionFun, Options),
PathPattern = rabbit_db_binding:khepri_route_path(
_VHost = ?KHEPRI_WILDCARD_STAR,
_ExchangeName = ?KHEPRI_WILDCARD_STAR,
Expand Down Expand Up @@ -1543,7 +1552,7 @@ get_feature_state(Node) ->
khepri_db_migration_enable(#{feature_name := FeatureName}) ->
maybe
ok ?= sync_cluster_membership_from_mnesia(FeatureName),
ok ?= unregister_all_projections(),
ok ?= unregister_legacy_projections(),
ok ?= register_projections(),
migrate_mnesia_tables(FeatureName)
end.
Expand Down