summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniil Fedotov <hairyhum@gmail.com>2018-07-24 14:36:51 +0100
committerDaniil Fedotov <hairyhum@gmail.com>2018-07-24 14:36:51 +0100
commite5f4cbd2348270a66e508023d76ad9578276d476 (patch)
tree29824f4eada746bca284618aa595c76d1a7d0429 /src
parentddbc8642b83897d5389104a32740377c049bd3cb (diff)
downloadrabbitmq-server-git-e5f4cbd2348270a66e508023d76ad9578276d476.tar.gz
Prepare bindings table in a separate recover function.
Before #567 all binding recover functions were executed once on node restart. Executing table_filter can be expensive with high number of vhosts and bindings and effectively should be called only once. Moved to a separate function, which should be called from the global recovery function (`rabbit_vhost:recover/0`)
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_binding.erl24
-rw-r--r--src/rabbit_vhost.erl4
2 files changed, 18 insertions, 10 deletions
diff --git a/src/rabbit_binding.erl b/src/rabbit_binding.erl
index 090e30b2b4..ae83cf6d4a 100644
--- a/src/rabbit_binding.erl
+++ b/src/rabbit_binding.erl
@@ -17,7 +17,7 @@
-module(rabbit_binding).
-include("rabbit.hrl").
--export([recover/2, exists/1, add/2, add/3, remove/1, remove/3, list/1]).
+-export([recover/0, recover/2, exists/1, add/2, add/3, remove/1, remove/3, list/1]).
-export([list_for_source/1, list_for_destination/1,
list_for_source_and_destination/2]).
-export([new_deletions/0, combine_deletions/2, add_deletion/3,
@@ -102,16 +102,20 @@
routing_key, arguments,
vhost]).
-recover(XNames, QNames) ->
+%% Global table recover
+recover() ->
rabbit_misc:table_filter(
- fun (Route) ->
- mnesia:read({rabbit_semi_durable_route, Route}) =:= []
- end,
- fun (Route, true) ->
- ok = mnesia:write(rabbit_semi_durable_route, Route, write);
- (_Route, false) ->
- ok
- end, rabbit_durable_route),
+ fun (Route) ->
+ mnesia:read({rabbit_semi_durable_route, Route}) =:= []
+ end,
+ fun (Route, true) ->
+ ok = mnesia:write(rabbit_semi_durable_route, Route, write);
+ (_Route, false) ->
+ ok
+ end, rabbit_durable_route).
+
+%% Per-vhost recover
+recover(XNames, QNames) ->
XNameSet = sets:from_list(XNames),
QNameSet = sets:from_list(QNames),
SelectSet = fun (#resource{kind = exchange}) -> XNameSet;
diff --git a/src/rabbit_vhost.erl b/src/rabbit_vhost.erl
index e97af7a757..fdcba35db2 100644
--- a/src/rabbit_vhost.erl
+++ b/src/rabbit_vhost.erl
@@ -52,6 +52,10 @@ recover() ->
rabbit_amqqueue:on_node_down(node()),
rabbit_amqqueue:warn_file_limit(),
+
+ %% Prepare rabbit_semi_durable_route table
+ rabbit_binding:recover(),
+
%% rabbit_vhost_sup_sup will start the actual recovery.
%% So recovery will be run every time a vhost supervisor is restarted.
ok = rabbit_vhost_sup_sup:start(),