Skip to content

Commit 3860c1e

Browse files
committed
rabbit_khepri: Unregister all projections when enabling khepri_db ff
1 parent a771263 commit 3860c1e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

deps/rabbit/src/rabbit_khepri.erl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,27 @@ 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
1111+
Ret :: ok | timeout_error().
1112+
1113+
unregister_all_projections() ->
1114+
%% Note that we don't use `all' since `khepri_mnesia_migration' also
1115+
%% creates a projection table which we don't want to unregister. Instead
1116+
%% we list all of the currently used projection names:
1117+
Names = [
1118+
rabbit_khepri_exchange,
1119+
rabbit_khepri_queue,
1120+
rabbit_khepri_vhost,
1121+
rabbit_khepri_users,
1122+
rabbit_khepri_global_rtparams,
1123+
rabbit_khepri_per_vhost_rtparams,
1124+
rabbit_khepri_user_permissions,
1125+
rabbit_khepri_bindings,
1126+
rabbit_khepri_index_route,
1127+
rabbit_khepri_topic_trie
1128+
],
1129+
khepri:unregister_projections(?STORE_ID, Names).
1130+
11101131
register_projections() ->
11111132
RegFuns = [fun register_rabbit_exchange_projection/0,
11121133
fun register_rabbit_queue_projection/0,
@@ -1522,6 +1543,7 @@ get_feature_state(Node) ->
15221543
khepri_db_migration_enable(#{feature_name := FeatureName}) ->
15231544
maybe
15241545
ok ?= sync_cluster_membership_from_mnesia(FeatureName),
1546+
ok ?= unregister_all_projections(),
15251547
ok ?= register_projections(),
15261548
migrate_mnesia_tables(FeatureName)
15271549
end.

0 commit comments

Comments
 (0)