diff options
| author | Daniil Fedotov <hairyhum@gmail.com> | 2019-01-15 17:26:45 +0400 |
|---|---|---|
| committer | Daniil Fedotov <hairyhum@gmail.com> | 2019-01-15 17:31:15 +0400 |
| commit | 2b7f157b4a6d2dcee6622b8cd6afc4326d0adb54 (patch) | |
| tree | 14e67335c904c52220ed078dfac631d8fecbb6d3 /src | |
| parent | 45632289309e80a38348ed936961330a4ae0763b (diff) | |
| download | rabbitmq-server-git-2b7f157b4a6d2dcee6622b8cd6afc4326d0adb54.tar.gz | |
Add an upgrade function to remove all default bindings.
Versions before 3.8 create default bindings for queues in the database.
Since #1721 they are replaced with placeholders only for list operations.
We need to cleanup the bindings to improve binding performance with
older queues.
[#163224049]
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_binding.erl | 2 | ||||
| -rw-r--r-- | src/rabbit_upgrade_functions.erl | 18 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/rabbit_binding.erl b/src/rabbit_binding.erl index 3a9c9b4427..d8312daede 100644 --- a/src/rabbit_binding.erl +++ b/src/rabbit_binding.erl @@ -27,6 +27,8 @@ -export([has_for_source/1, remove_for_source/1, remove_for_destination/2, remove_transient_for_destination/1]). +-export([implicit_for_destination/1, reverse_binding/1]). + -define(DEFAULT_EXCHANGE(VHostPath), #resource{virtual_host = VHostPath, kind = exchange, name = <<>>}). diff --git a/src/rabbit_upgrade_functions.erl b/src/rabbit_upgrade_functions.erl index 449d57b823..b1bb89f576 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({default_bindings, mnesia, [semi_durable_route]}). + %% ------------------------------------------------------------------- -spec remove_user_scope() -> 'ok'. @@ -654,6 +657,21 @@ exchange_options(Table) -> [name, type, durable, auto_delete, internal, arguments, scratches, policy, operator_policy, decorators, options]). +default_bindings() -> + %% The bindings are not used anyway, + %% and are replaced by placeholders. + %% It should be safe to remove them dirty. + Queues = mnesia:dirty_all_keys(rabbit_queue), + [begin + Binding = rabbit_binding:implicit_for_destination(Q), + mnesia:dirty_delete(rabbit_route, Binding), + mnesia:dirty_delete(rabbit_durable_route, Binding), + mnesia:dirty_delete(rabbit_semi_durable_route, Binding), + mnesia:dirty_delete(rabbit_reverse_route, + rabbit_binding:reverse_binding(Binding)) + end + || Q <- Queues]. + %%-------------------------------------------------------------------- transform(TableName, Fun, FieldList) -> |
