diff options
-rw-r--r-- | src/app_utils.erl | 8 | ||||
-rw-r--r-- | src/rabbit_cli.erl | 13 | ||||
-rw-r--r-- | src/rabbit_control_main.erl | 5 | ||||
-rw-r--r-- | src/rabbit_plugins_main.erl | 4 |
4 files changed, 23 insertions, 7 deletions
diff --git a/src/app_utils.erl b/src/app_utils.erl index 87e6fa0b..ad270518 100644 --- a/src/app_utils.erl +++ b/src/app_utils.erl @@ -62,7 +62,13 @@ start_applications(Apps, ErrorHandler) -> stop_applications(Apps, ErrorHandler) -> manage_applications(fun lists:foldr/3, - fun application:stop/1, + %% Mitigation for bug 26467. TODO remove when we fix it. + fun (mnesia) -> + timer:sleep(1000), + application:stop(mnesia); + (App) -> + application:stop(App) + end, fun application:start/1, not_started, ErrorHandler, diff --git a/src/rabbit_cli.erl b/src/rabbit_cli.erl index 2981f3b2..47505b3d 100644 --- a/src/rabbit_cli.erl +++ b/src/rabbit_cli.erl @@ -17,7 +17,7 @@ -module(rabbit_cli). -include("rabbit_cli.hrl"). --export([main/3, parse_arguments/4]). +-export([main/3, parse_arguments/4, rpc_call/4]). %%---------------------------------------------------------------------------- @@ -35,6 +35,7 @@ -spec(parse_arguments/4 :: ([{atom(), [{string(), optdef()}]} | atom()], [{string(), optdef()}], string(), [string()]) -> parse_result()). +-spec(rpc_call/4 :: (node(), atom(), atom(), [any()]) -> any()). -endif. @@ -185,3 +186,13 @@ print_error(Format, Args) -> fmt_stderr("Error: " ++ Format, Args). print_badrpc_diagnostics(Nodes) -> fmt_stderr(rabbit_nodes:diagnostics(Nodes), []). +%% If the server we are talking to has non-standard net_ticktime, and +%% our connection lasts a while, we could get disconnected because of +%% a timeout unless we set our ticktime to be the same. So let's do +%% that. +rpc_call(Node, Mod, Fun, Args) -> + case rpc:call(Node, net_kernel, get_net_ticktime, [], ?RPC_TIMEOUT) of + {badrpc, _} = E -> E; + Time -> net_kernel:set_net_ticktime(Time, 0), + rpc:call(Node, Mod, Fun, Args, ?RPC_TIMEOUT) + end. diff --git a/src/rabbit_control_main.erl b/src/rabbit_control_main.erl index 6e789e37..a931eef0 100644 --- a/src/rabbit_control_main.erl +++ b/src/rabbit_control_main.erl @@ -21,6 +21,8 @@ -export([start/0, stop/0, parse_arguments/2, action/5, sync_queue/1, cancel_sync_queue/1]). +-import(rabbit_cli, [rpc_call/4]). + -define(EXTERNAL_CHECK_INTERVAL, 1000). -define(GLOBAL_DEFS(Node), [?QUIET_DEF, ?NODE_DEF(Node)]). @@ -692,9 +694,6 @@ list_to_binary_utf8(L) -> error -> throw({error, {not_utf_8, L}}) end. -rpc_call(Node, Mod, Fun, Args) -> - rpc:call(Node, Mod, Fun, Args, ?RPC_TIMEOUT). - %% escape does C-style backslash escaping of non-printable ASCII %% characters. We don't escape characters above 127, since they may %% form part of UTF-8 strings. diff --git a/src/rabbit_plugins_main.erl b/src/rabbit_plugins_main.erl index 7fd10435..49f699c5 100644 --- a/src/rabbit_plugins_main.erl +++ b/src/rabbit_plugins_main.erl @@ -169,7 +169,7 @@ format_plugins(Node, Pattern, Opts, #cli{all = All, EnabledImplicitly = Implicit -- Enabled, {StatusMsg, Running} = - case rpc:call(Node, rabbit_plugins, active, [], ?RPC_TIMEOUT) of + case rabbit_cli:rpc_call(Node, rabbit_plugins, active, []) of {badrpc, _} -> {"[failed to contact ~s - status not shown]", []}; Active -> {"* = running on ~s", Active} end, @@ -275,7 +275,7 @@ sync(Node, ForceOnline, #cli{file = File}) -> rpc_call(Node, Online, Mod, Fun, Args) -> io:format("~nApplying plugin configuration to ~s...", [Node]), - case rpc:call(Node, Mod, Fun, Args) of + case rabbit_cli:rpc_call(Node, Mod, Fun, Args) of {ok, [], []} -> io:format(" nothing to do.~n", []); {ok, Start, []} -> |