diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2014-02-26 16:42:44 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2014-02-26 16:42:44 +0000 |
commit | 40994ba4a0141cb2e0ca1592ee6668b0bcfe474b (patch) | |
tree | 19bd5413c856b8b8c8aab3bbfab90abf24fe8a39 | |
parent | da9169d6cf2ec9b02169a8298a3526cbad18358c (diff) | |
parent | 22238accee51db7ec3819efd7e3607c2cf5e23c2 (diff) | |
download | rabbitmq-server-bug26027.tar.gz |
Merge in defaultbug26027
-rw-r--r-- | src/rabbit_autoheal.erl | 13 | ||||
-rw-r--r-- | src/rabbit_misc.erl | 10 |
2 files changed, 14 insertions, 9 deletions
diff --git a/src/rabbit_autoheal.erl b/src/rabbit_autoheal.erl index b631d9c9..3aa32c09 100644 --- a/src/rabbit_autoheal.erl +++ b/src/rabbit_autoheal.erl @@ -83,7 +83,7 @@ enabled() -> %% stopped - all nodes can now start again rabbit_down(Node, {winner_waiting, [Node], Notify}) -> rabbit_log:info("Autoheal: final node has stopped, starting...~n",[]), - [{rabbit_outside_app_process, N} ! autoheal_safe_to_start || N <- Notify], + notify_safe(Notify), not_healing; rabbit_down(Node, {winner_waiting, WaitFor, Notify}) -> @@ -95,6 +95,14 @@ rabbit_down(_Node, State) -> node_down(_Node, not_healing) -> not_healing; + +node_down(Node, {winner_waiting, _, Notify}) -> + rabbit_log:info("Autoheal: aborting - ~p went down~n", [Node]), + %% Make sure any nodes waiting for us start - it won't necessarily + %% heal the partition but at least they won't get stuck. + notify_safe(Notify), + not_healing; + node_down(Node, _State) -> rabbit_log:info("Autoheal: aborting - ~p went down~n", [Node]), not_healing. @@ -162,6 +170,9 @@ handle_msg(_, restarting, _Partitions) -> send(Node, Msg) -> {?SERVER, Node} ! {autoheal_msg, Msg}. +notify_safe(Notify) -> + [{rabbit_outside_app_process, N} ! autoheal_safe_to_start || N <- Notify]. + make_decision(AllPartitions) -> Sorted = lists:sort([{partition_value(P), P} || P <- AllPartitions]), [[Winner | _] | Rest] = lists:reverse([P || {_, P} <- Sorted]), diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index 848c4a87..ab1c6063 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -685,7 +685,7 @@ pid_to_string(Pid) when is_pid(Pid) -> <<131,103,100,NodeLen:16,NodeBin:NodeLen/binary,Id:32,Ser:32,Cre:8>> = term_to_binary(Pid), Node = binary_to_term(<<131,100,NodeLen:16,NodeBin:NodeLen/binary>>), - format("<~w.~B.~B.~B>", [Node, Cre, Id, Ser]). + format("<~s.~B.~B.~B>", [Node, Cre, Id, Ser]). %% inverse of above string_to_pid(Str) -> @@ -695,13 +695,7 @@ string_to_pid(Str) -> case re:run(Str, "^<(.*)\\.(\\d+)\\.(\\d+)\\.(\\d+)>\$", [{capture,all_but_first,list}]) of {match, [NodeStr, CreStr, IdStr, SerStr]} -> - %% the NodeStr atom might be quoted, so we have to parse - %% it rather than doing a simple list_to_atom - NodeAtom = case erl_scan:string(NodeStr) of - {ok, [{atom, _, X}], _} -> X; - {error, _, _} -> throw(Err) - end, - <<131,NodeEnc/binary>> = term_to_binary(NodeAtom), + <<131,NodeEnc/binary>> = term_to_binary(list_to_atom(NodeStr)), [Cre, Id, Ser] = lists:map(fun list_to_integer/1, [CreStr, IdStr, SerStr]), binary_to_term(<<131,103,NodeEnc/binary,Id:32,Ser:32,Cre:8>>); |