summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rabbit_binding.erl17
-rw-r--r--src/rabbit_upgrade_functions.erl22
2 files changed, 38 insertions, 1 deletions
diff --git a/src/rabbit_binding.erl b/src/rabbit_binding.erl
index 3a9c9b4427..bb1c754b5c 100644
--- a/src/rabbit_binding.erl
+++ b/src/rabbit_binding.erl
@@ -25,7 +25,10 @@
-export([info_keys/0, info/1, info/2, info_all/1, info_all/2, info_all/4]).
%% these must all be run inside a mnesia tx
-export([has_for_source/1, remove_for_source/1,
- remove_for_destination/2, remove_transient_for_destination/1]).
+ remove_for_destination/2, remove_transient_for_destination/1,
+ remove_default_exchange_binding_rows_of/1]).
+
+-export([implicit_for_destination/1, reverse_binding/1]).
-define(DEFAULT_EXCHANGE(VHostPath), #resource{virtual_host = VHostPath,
kind = exchange,
@@ -249,6 +252,18 @@ remove(Src, Dst, B, ActingUser) ->
B#binding.source, [B], new_deletions(), false),
process_deletions(Deletions, ActingUser).
+%% Implicit bindings are implicit as of rabbitmq/rabbitmq-server#1721.
+remove_default_exchange_binding_rows_of(Dst = #resource{}) ->
+ case rabbit_binding:implicit_for_destination(Dst) of
+ [Binding] ->
+ mnesia:dirty_delete(rabbit_durable_route, Binding);
+ _ ->
+ %% no binding to remove or
+ %% a competing tx has beaten us to it?
+ ok
+ end,
+ ok.
+
list(VHostPath) ->
VHostResource = rabbit_misc:r(VHostPath, '_'),
Route = #route{binding = #binding{source = VHostResource,
diff --git a/src/rabbit_upgrade_functions.erl b/src/rabbit_upgrade_functions.erl
index 449d57b823..6be812dad3 100644
--- a/src/rabbit_upgrade_functions.erl
+++ b/src/rabbit_upgrade_functions.erl
@@ -64,6 +64,9 @@
-rabbit_upgrade({queue_quorum_nodes, mnesia, [queue_type]}).
-rabbit_upgrade({exchange_options, mnesia, [operator_policies]}).
+%% TODO: move that to feature flags
+-rabbit_upgrade({remove_explicit_default_exchange_bindings, mnesia, [queue_state]}).
+
%% -------------------------------------------------------------------
-spec remove_user_scope() -> 'ok'.
@@ -104,6 +107,7 @@
-spec queue_quorum_nodes() -> 'ok'.
-spec exchange_options() -> 'ok'.
+-spec remove_explicit_default_exchange_bindings() -> 'ok'.
%%--------------------------------------------------------------------
@@ -654,6 +658,24 @@ exchange_options(Table) ->
[name, type, durable, auto_delete, internal, arguments, scratches, policy,
operator_policy, decorators, options]).
+remove_explicit_default_exchange_bindings() ->
+ Tab = rabbit_durable_queue,
+ rabbit_table:wait([Tab]),
+ %% Default exchange bindings are now implicit
+ %% (not stored in the route tables).
+ %% It should be safe to remove them outside of a
+ %% transaction.
+ Queues = mnesia:dirty_all_keys(Tab),
+ N = length(Queues),
+ case N of
+ 0 -> ok;
+ _ ->
+ error_logger:info_msg("Will delete explicit default exchange bindings for ~p queues. "
+ "This can take some time...", [N]),
+ [rabbit_binding:remove_default_exchange_binding_rows_of(Q) || Q <- Queues]
+ end,
+ ok.
+
%%--------------------------------------------------------------------
transform(TableName, Fun, FieldList) ->