Skip to content

Commit 1156232

Browse files
authored
Merge pull request #14407 from rabbitmq/fix-topic-permissions-definitions-import
rabbit_definitions: Import topic permissions after exchanges
2 parents b76e634 + 5bcbfad commit 1156232

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

deps/rabbit/src/rabbit_db_exchange.erl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,12 @@ create_or_get_in_mnesia(#exchange{name = XName} = X) ->
409409
end).
410410

411411
create_or_get_in_khepri(#exchange{name = XName} = X) ->
412-
Path = khepri_exchange_path(XName),
413-
case rabbit_khepri:create(Path, X) of
412+
Path0 = khepri_exchange_path(XName),
413+
Path1 = khepri_path:combine_with_conditions(
414+
Path0, [#if_any{conditions =
415+
[#if_node_exists{exists = false},
416+
#if_has_payload{has_payload = false}]}]),
417+
case rabbit_khepri:put(Path1, X) of
414418
ok ->
415419
{new, X};
416420
{error, {khepri, mismatching_node, #{node_props := #{data := ExistingX}}}} ->

deps/rabbit/src/rabbit_definitions.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,9 @@ apply_defs(Map, ActingUser, SuccessFun) when is_function(SuccessFun) ->
508508
concurrent_for_all(vhosts, ActingUser, Map, fun add_vhost/2),
509509
validate_limits(Map),
510510
concurrent_for_all(permissions, ActingUser, Map, fun add_permission/2),
511-
concurrent_for_all(topic_permissions, ActingUser, Map, fun add_topic_permission/2),
512511

513512
concurrent_for_all(exchanges, ActingUser, Map, fun add_exchange/2),
513+
concurrent_for_all(topic_permissions, ActingUser, Map, fun add_topic_permission/2),
514514

515515
sequential_for_all(global_parameters, ActingUser, Map, fun add_global_parameter/2),
516516
%% importing policies concurrently can be unsafe as queues will be getting

0 commit comments

Comments
 (0)