Skip to content

Commit 92c572e

Browse files
committed
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.
1 parent b76e634 commit 92c572e

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
@@ -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)