From 379a34630cb543782941a306de4187386807aca5 Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Thu, 20 Nov 2014 09:49:27 +0000 Subject: Sleep to mitigate bug 26467 in the 3.4.x series. --- src/app_utils.erl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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, -- cgit v1.2.1 From dd7691db091e2cab7f059515b66d054bbd911d44 Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Thu, 20 Nov 2014 15:33:38 +0000 Subject: Sync ticktime with server. --- src/rabbit_cli.erl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/rabbit_cli.erl b/src/rabbit_cli.erl index 2981f3b2..3fc32039 100644 --- a/src/rabbit_cli.erl +++ b/src/rabbit_cli.erl @@ -57,7 +57,10 @@ main(ParseFun, DoFun, UsageMod) -> %% The reason we don't use a try/catch here is that rpc:call turns %% thrown errors into normal return values - case catch DoFun(Command, Node, Args, Opts) of + case catch begin + sync_ticktime(Node), + DoFun(Command, Node, Args, Opts) + end of ok -> rabbit_misc:quit(0); {'EXIT', {function_clause, [{?MODULE, action, _} | _]}} -> %% < R15 @@ -185,3 +188,12 @@ 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 conncetion 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. +sync_ticktime(Node) -> + case rpc:call(Node, net_kernel, get_net_ticktime, []) of + {badrpc, _} = E -> throw(E); %% To be caught in main/3 + Time -> net_kernel:set_net_ticktime(Time, 0) + end. -- cgit v1.2.1 From d14953fcf04e6c983e21d22bfff9481182c41617 Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Thu, 20 Nov 2014 16:51:26 +0000 Subject: Be a bit more sensible with syncing the ticktime; only do it when RPCing into the node (since there are plenty of commands where we do not expect the node to be up, which the previous changeset breaks...) --- src/rabbit_cli.erl | 17 ++++++++--------- src/rabbit_control_main.erl | 5 ++--- src/rabbit_plugins_main.erl | 4 ++-- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/rabbit_cli.erl b/src/rabbit_cli.erl index 3fc32039..ff345c6d 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. @@ -57,10 +58,7 @@ main(ParseFun, DoFun, UsageMod) -> %% The reason we don't use a try/catch here is that rpc:call turns %% thrown errors into normal return values - case catch begin - sync_ticktime(Node), - DoFun(Command, Node, Args, Opts) - end of + case catch DoFun(Command, Node, Args, Opts) of ok -> rabbit_misc:quit(0); {'EXIT', {function_clause, [{?MODULE, action, _} | _]}} -> %% < R15 @@ -189,11 +187,12 @@ print_badrpc_diagnostics(Nodes) -> fmt_stderr(rabbit_nodes:diagnostics(Nodes), []). %% If the server we are talking to has non-standard net_ticktime, and -%% our conncetion lasts a while, we could get disconnected because of +%% 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. -sync_ticktime(Node) -> - case rpc:call(Node, net_kernel, get_net_ticktime, []) of +rpc_call(Node, Mod, Fun, Args) -> + case rpc:call(Node, net_kernel, get_net_ticktime, [], ?RPC_TIMEOUT) of {badrpc, _} = E -> throw(E); %% To be caught in main/3 - Time -> net_kernel:set_net_ticktime(Time, 0) + 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, []} -> -- cgit v1.2.1 From 563e1709c2affcd6382525c0beb6ea45fa0fb8d5 Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Thu, 20 Nov 2014 17:14:10 +0000 Subject: We don't need to throw that any more, maintain an API like that of rpc:call/4. --- src/rabbit_cli.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rabbit_cli.erl b/src/rabbit_cli.erl index ff345c6d..47505b3d 100644 --- a/src/rabbit_cli.erl +++ b/src/rabbit_cli.erl @@ -192,7 +192,7 @@ print_badrpc_diagnostics(Nodes) -> %% that. rpc_call(Node, Mod, Fun, Args) -> case rpc:call(Node, net_kernel, get_net_ticktime, [], ?RPC_TIMEOUT) of - {badrpc, _} = E -> throw(E); %% To be caught in main/3 + {badrpc, _} = E -> E; Time -> net_kernel:set_net_ticktime(Time, 0), rpc:call(Node, Mod, Fun, Args, ?RPC_TIMEOUT) end. -- cgit v1.2.1