Skip to content

More efficient virtual host recovery: prepare semi-durable binding table once instead of each time a virtual host is recovered #1650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/rabbit_binding.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -102,16 +102,20 @@
routing_key, arguments,
vhost]).

recover(XNames, QNames) ->
%% Global table recovery
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).

%% Virtual host-specific recovery
recover(XNames, QNames) ->
XNameSet = sets:from_list(XNames),
QNameSet = sets:from_list(QNames),
SelectSet = fun (#resource{kind = exchange}) -> XNameSet;
Expand Down
4 changes: 4 additions & 0 deletions src/rabbit_vhost.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down