Skip to content

Commit ac1696b

Browse files
Merge pull request #12266 from rabbitmq/md/khepri/singular-projection-names
2 parents 192426d + c363ae0 commit ac1696b

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

deps/rabbit/src/rabbit_db_binding.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
-define(MNESIA_SEMI_DURABLE_TABLE, rabbit_semi_durable_route).
5454
-define(MNESIA_REVERSE_TABLE, rabbit_reverse_route).
5555
-define(MNESIA_INDEX_TABLE, rabbit_index_route).
56-
-define(KHEPRI_BINDINGS_PROJECTION, rabbit_khepri_bindings).
56+
-define(KHEPRI_BINDINGS_PROJECTION, rabbit_khepri_binding).
5757
-define(KHEPRI_INDEX_ROUTE_PROJECTION, rabbit_khepri_index_route).
5858

5959
%% -------------------------------------------------------------------

deps/rabbit/src/rabbit_db_rtparams.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
]).
2424

2525
-define(MNESIA_TABLE, rabbit_runtime_parameters).
26-
-define(KHEPRI_GLOBAL_PROJECTION, rabbit_khepri_global_rtparams).
27-
-define(KHEPRI_VHOST_PROJECTION, rabbit_khepri_per_vhost_rtparams).
26+
-define(KHEPRI_GLOBAL_PROJECTION, rabbit_khepri_global_rtparam).
27+
-define(KHEPRI_VHOST_PROJECTION, rabbit_khepri_per_vhost_rtparam).
2828
-define(any(Value), case Value of
2929
'_' -> ?KHEPRI_WILDCARD_STAR;
3030
_ -> Value

deps/rabbit/src/rabbit_db_user.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@
7575
-define(MNESIA_TABLE, rabbit_user).
7676
-define(PERM_MNESIA_TABLE, rabbit_user_permission).
7777
-define(TOPIC_PERM_MNESIA_TABLE, rabbit_topic_permission).
78-
-define(KHEPRI_USERS_PROJECTION, rabbit_khepri_users).
79-
-define(KHEPRI_PERMISSIONS_PROJECTION, rabbit_khepri_user_permissions).
78+
-define(KHEPRI_USERS_PROJECTION, rabbit_khepri_user).
79+
-define(KHEPRI_PERMISSIONS_PROJECTION, rabbit_khepri_user_permission).
8080

8181
%% -------------------------------------------------------------------
8282
%% create().

deps/rabbit/src/rabbit_khepri.erl

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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

11311140
register_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

11831192
register_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

11901199
register_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

11971206
register_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

12061215
register_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) ->
15431552
khepri_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

Comments
 (0)