Skip to content

Commit

Permalink
Manually backport #3137
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin committed Jun 29, 2021
1 parent d1ebb92 commit 115136b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
19 changes: 10 additions & 9 deletions deps/rabbit/src/rabbit_binding.erl
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,16 @@ new(Src, RoutingKey, Dst, Arguments) ->
'ok'.

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).
rabbit_misc:execute_mnesia_transaction(
fun () ->
mnesia:lock({table, rabbit_durable_route}, read),
mnesia:lock({table, rabbit_semi_durable_route}, write),
Routes = rabbit_misc:dirty_read_all(rabbit_durable_route),
Fun = fun(Route) ->
mnesia:dirty_write(rabbit_semi_durable_route, Route)
end,
lists:foreach(Fun, Routes)
end).

%% Virtual host-specific recovery
recover(XNames, QNames) ->
Expand Down
10 changes: 8 additions & 2 deletions deps/rabbit/src/rabbit_vhost.erl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ recover() ->
rabbit_amqqueue:warn_file_limit(),

%% Prepare rabbit_semi_durable_route table
rabbit_binding:recover(),
{Time, _} = timer:tc(fun() ->
rabbit_binding:recover()
end),
_ = rabbit_log:debug("rabbit_binding:recover/0 completed in ~fs", [Time/1000000]),

%% rabbit_vhost_sup_sup will start the actual recovery.
%% So recovery will be run every time a vhost supervisor is restarted.
Expand All @@ -52,7 +55,10 @@ recover(VHost) ->
{RecoveredClassic, FailedClassic, Quorum} = rabbit_amqqueue:recover(VHost),
AllQs = RecoveredClassic ++ FailedClassic ++ Quorum,
QNames = [amqqueue:get_name(Q) || Q <- AllQs],
ok = rabbit_binding:recover(rabbit_exchange:recover(VHost), QNames),
{Time, ok} = timer:tc(fun() ->
rabbit_binding:recover(rabbit_exchange:recover(VHost), QNames)
end),
_ = rabbit_log:debug("rabbit_binding:recover/2 for vhost ~s completed in ~fs", [VHost, Time/1000000]),
ok = rabbit_amqqueue:start(RecoveredClassic),
%% Start queue mirrors.
ok = rabbit_mirror_queue_misc:on_vhost_up(VHost),
Expand Down

0 comments on commit 115136b

Please sign in to comment.