summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-03-10 14:18:56 +0000
committerSimon MacMullen <simon@rabbitmq.com>2014-03-10 14:18:56 +0000
commita1d7686e12f0c2d6b9eb5c8cb53a3f49fbb1c3a4 (patch)
tree9ce92665fe41c9c4d613f7ff79291d628c7a30d4 /src
parent55c2a86fd2eda42e307e1ac741ee8bb94f92707e (diff)
downloadrabbitmq-server-git-a1d7686e12f0c2d6b9eb5c8cb53a3f49fbb1c3a4.tar.gz
Get the leader to transition directly to winner or loser state if that's where it's going, or wait in a special lead_waiting status if neither, so that if we get any more autoheal requests we can ignore them.
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_autoheal.erl19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/rabbit_autoheal.erl b/src/rabbit_autoheal.erl
index 3aa32c09a6..7b27ac82f8 100644
--- a/src/rabbit_autoheal.erl
+++ b/src/rabbit_autoheal.erl
@@ -89,6 +89,12 @@ rabbit_down(Node, {winner_waiting, [Node], Notify}) ->
rabbit_down(Node, {winner_waiting, WaitFor, Notify}) ->
{winner_waiting, WaitFor -- [Node], Notify};
+rabbit_down(Node, {leader_waiting, [Node]}) ->
+ not_healing;
+
+rabbit_down(Node, {leader_waiting, WaitFor}) ->
+ {leader_waiting, WaitFor -- [Node]};
+
rabbit_down(_Node, State) ->
%% ignore, we already cancelled the autoheal process
State.
@@ -121,9 +127,18 @@ handle_msg({request_start, Node},
" * Winner: ~p~n"
" * Losers: ~p~n",
[AllPartitions, Winner, Losers]),
- send(Winner, {become_winner, Losers}),
[send(L, {winner_is, Winner}) || L <- Losers],
- not_healing
+ ShortCut = fun(Msg) ->
+ handle_msg(Msg, not_healing, Partitions)
+ end,
+ case {node() =:= Winner, lists:member(node(), Losers)} of
+ true -> ShortCut({become_winner, Losers});
+ false -> send(Winner, {become_winner, Losers}),
+ case lists:member(node(), Losers) of
+ true -> ShortCut({winner_is, Winner});
+ false -> {leader_waiting, Losers}
+ end
+ end
end;
handle_msg({request_start, Node},