From ac2041abf768e94c38b0c9906959568e66183b1a Mon Sep 17 00:00:00 2001 From: Nick Vatamaniuc Date: Wed, 1 May 2019 10:05:44 -0400 Subject: Revert to using the older rexi kill messages In a future release, once all nodes know how to handle kill_all message will re-enable it. In low traffic clusters this might not be an issue, as the extra workers would time out and exit eventually, but in busy clusters this could cause couch_server and other message backups as while the upgrade is happening workers would not be terminate quickly enough. --- src/rexi/src/rexi.erl | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/rexi/src/rexi.erl b/src/rexi/src/rexi.erl index 21e2b5388..712e4c3c3 100644 --- a/src/rexi/src/rexi.erl +++ b/src/rexi/src/rexi.erl @@ -80,13 +80,22 @@ kill(Node, Ref) -> %% No rexi_EXIT message will be sent. -spec kill_all([{node(), reference()}]) -> ok. kill_all(NodeRefs) when is_list(NodeRefs) -> - PerNodeMap = lists:foldl(fun({Node, Ref}, Acc) -> - maps:update_with(Node, fun(Refs) -> [Ref | Refs] end, [Ref], Acc) - end, #{}, NodeRefs), - maps:map(fun(Node, Refs) -> - rexi_utils:send(rexi_utils:server_pid(Node), cast_msg({kill_all, Refs})) - end, PerNodeMap), - ok. + lists:foreach(fun({Node, Ref}) -> kill(Node, Ref) end, NodeRefs). + +%% Upgrade clause. Since kill_all is a new message, nodes in a mixed +%% cluster won't know how to process it. In that case, opt to send the older +%% kill message. In a future release, once all the nodes know how to handle +%% kill_all, switch to using this implemention +%% +%% kill_all(NodeRefs) when is_list(NodeRefs) -> +%% PerNodeMap = lists:foldl(fun({Node, Ref}, Acc) -> +%% maps:update_with(Node, fun(Refs) -> [Ref | Refs] end, [Ref], Acc) +%% end, #{}, NodeRefs), +%% maps:map(fun(Node, Refs) -> +%% rexi_utils:send(rexi_utils:server_pid(Node), cast_msg({kill_all, Refs})) +%% end, PerNodeMap), +%% ok. + %% @equiv async_server_call(Server, self(), Request) -spec async_server_call(pid() | {atom(),node()}, any()) -> reference(). -- cgit v1.2.1