Skip to content

Commit 31733d8

Browse files
authored
Merge pull request #14409 from rabbitmq/mergify/bp/v4.1.x/pr-14407
rabbit_definitions: Import topic permissions after exchanges (backport #14407)
2 parents 5de5f89 + a15b4a2 commit 31733d8

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
@@ -507,9 +507,9 @@ apply_defs(Map, ActingUser, SuccessFun) when is_function(SuccessFun) ->
507507
concurrent_for_all(vhosts, ActingUser, Map, fun add_vhost/2),
508508
validate_limits(Map),
509509
concurrent_for_all(permissions, ActingUser, Map, fun add_permission/2),
510-
concurrent_for_all(topic_permissions, ActingUser, Map, fun add_topic_permission/2),
511510

512511
concurrent_for_all(exchanges, ActingUser, Map, fun add_exchange/2),
512+
concurrent_for_all(topic_permissions, ActingUser, Map, fun add_topic_permission/2),
513513

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

0 commit comments

Comments
 (0)