diff --git a/deps/rabbit/src/rabbit_binding.erl b/deps/rabbit/src/rabbit_binding.erl index 8b313e1f377e..c35e6a6cfc48 100644 --- a/deps/rabbit/src/rabbit_binding.erl +++ b/deps/rabbit/src/rabbit_binding.erl @@ -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) -> diff --git a/deps/rabbit/src/rabbit_vhost.erl b/deps/rabbit/src/rabbit_vhost.erl index 859293e58d23..adbd9cde2260 100644 --- a/deps/rabbit/src/rabbit_vhost.erl +++ b/deps/rabbit/src/rabbit_vhost.erl @@ -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. @@ -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),