Skip to content

Commit e4fb334

Browse files
dumbbellmergify[bot]
authored andcommitted
rabbit_definitions: Import topic permissions after exchanges
[Why] Topic permissions depend on an exchange, in addition to a user and a vhost like other permissions. This fixes a bug where an exchange imported after a topic permission that depends on it caused the following crash when Khepri is used: {case_clause,{error,{khepri,mismatching_node, #{node_name => <<"exchange_name">>, node_props => #{payload_version => 1}, node_path => [rabbitmq,vhosts,<<"/">>,exchanges, <<"exchange_name">>], condition => {if_node_exists,false}, node_is_target => true}}}} The crash comes from the fact that the exchange code expect to either create the tree node in Khepri for that exchange, or there is an existing tree node holding an exchange tree node. Here, there was a tree node created implicitly when the topic permission was stored, but that tree node didn't have an exchange record (because the exchange was not imported yet). [How] We simply swap the import of topic permissions and exchanges. (cherry picked from commit 92c572e)
1 parent 5de5f89 commit e4fb334

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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)