diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2013-03-05 12:38:51 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2013-03-05 12:38:51 +0000 |
commit | 9563fcd45ea69ec4ed353acd1b72d577f6566da3 (patch) | |
tree | cbf7a31112cd755648748b989ea9bc595d369eea /src | |
parent | 6bacb8a803bbfef2187a6fdd3455d44519558d0a (diff) | |
parent | 5ae47d98f0fe2f67503646316d7a0df186be80b6 (diff) | |
download | rabbitmq-server-9563fcd45ea69ec4ed353acd1b72d577f6566da3.tar.gz |
Merge default
Diffstat (limited to 'src')
-rw-r--r-- | src/rabbit_error_logger_file_h.erl | 2 | ||||
-rw-r--r-- | src/rabbit_node_monitor.erl | 41 |
2 files changed, 42 insertions, 1 deletions
diff --git a/src/rabbit_error_logger_file_h.erl b/src/rabbit_error_logger_file_h.erl index 3efc9c0c..c00c1df9 100644 --- a/src/rabbit_error_logger_file_h.erl +++ b/src/rabbit_error_logger_file_h.erl @@ -76,6 +76,8 @@ init_file(File, PrevHandler) -> Error -> Error end. +handle_event({info_report, _, {_, std_info, _}}, State) -> + ok; %% filter out "application: foo; exited: stopped; type: temporary" handle_event(Event, State) -> error_logger_file_h:handle_event(Event, State). diff --git a/src/rabbit_node_monitor.erl b/src/rabbit_node_monitor.erl index 71c2c80a..5d587977 100644 --- a/src/rabbit_node_monitor.erl +++ b/src/rabbit_node_monitor.erl @@ -270,7 +270,46 @@ handle_dead_rabbit(Node) -> ok = rabbit_networking:on_node_down(Node), ok = rabbit_amqqueue:on_node_down(Node), ok = rabbit_alarm:on_node_down(Node), - ok = rabbit_mnesia:on_node_down(Node). + ok = rabbit_mnesia:on_node_down(Node), + case application:get_env(rabbit, cluster_partition_handling) of + {ok, pause_minority} -> + case majority() of + true -> ok; + false -> await_cluster_recovery() + end; + {ok, ignore} -> + ok; + {ok, Term} -> + rabbit_log:warning("cluster_partition_handling ~p unrecognised, " + "assuming 'ignore'~n", [Term]), + ok + end, + ok. + +majority() -> + Nodes = rabbit_mnesia:cluster_nodes(all), + Alive = [N || N <- Nodes, pong =:= net_adm:ping(N)], + length(Alive) / length(Nodes) > 0.5. + +await_cluster_recovery() -> + rabbit_log:warning("Cluster minority status detected - awaiting recovery~n", + []), + Nodes = rabbit_mnesia:cluster_nodes(all), + spawn(fun () -> + %% If our group leader is inside an application we are about + %% to stop, application:stop/1 does not return. + group_leader(whereis(init), self()), + rabbit:stop(), + wait_for_cluster_recovery(Nodes) + end). + +wait_for_cluster_recovery(Nodes) -> + [erlang:disconnect_node(Node) || Node <- Nodes], + case majority() of + true -> rabbit:start(); + false -> timer:sleep(1000), + wait_for_cluster_recovery(Nodes) + end. handle_live_rabbit(Node) -> ok = rabbit_alarm:on_node_up(Node), |