Skip to content

Commit 6bf0aac

Browse files
committed
rabbit_khepri: Rename legacy projection unregistration function, add docs
This function is meant to remove any projections which were mistakenly registered in 3.13.x rather than all existing projections.
1 parent 3df8116 commit 6bf0aac

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

deps/rabbit/src/rabbit_khepri.erl

Lines changed: 15 additions & 6 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,
@@ -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)