diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2012-10-15 18:11:38 +0100 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2012-10-15 18:11:38 +0100 |
commit | 572ec0a712306d4e4055884a8b80b063c3bf324f (patch) | |
tree | e00f0e651b63aa95f1f2a860b92e7121858a1815 | |
parent | 8404d0a107c9cf89e31b099b36bfa1866555900c (diff) | |
download | rabbitmq-server-572ec0a712306d4e4055884a8b80b063c3bf324f.tar.gz |
We can be partitioned from more than one node. And ignore the starting_partitioned_network, it seems to get copied across the network without marking which node it is from!
-rw-r--r-- | src/rabbit_mnesia.erl | 7 | ||||
-rw-r--r-- | src/rabbit_node_monitor.erl | 27 |
2 files changed, 17 insertions, 17 deletions
diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl index b07ac7d4..04ac0904 100644 --- a/src/rabbit_mnesia.erl +++ b/src/rabbit_mnesia.erl @@ -328,11 +328,8 @@ status() -> mnesia_partitions(Nodes) -> {Replies, _BadNodes} = rpc:multicall( - Nodes, rabbit_node_monitor, partition, []), - case [Reply || Reply = {_, R} <- Replies, R =/= none] of - [] -> none; - List -> List - end. + Nodes, rabbit_node_monitor, partitions, []), + [Reply || Reply = {_, R} <- Replies, R =/= []]. is_clustered() -> AllNodes = cluster_nodes(all), AllNodes =/= [] andalso AllNodes =/= [node()]. diff --git a/src/rabbit_node_monitor.erl b/src/rabbit_node_monitor.erl index 77aea364..b11c9d04 100644 --- a/src/rabbit_node_monitor.erl +++ b/src/rabbit_node_monitor.erl @@ -24,7 +24,7 @@ write_cluster_status/1, read_cluster_status/0, update_cluster_status/0, reset_cluster_status/0]). -export([notify_node_up/0, notify_joined_cluster/0, notify_left_cluster/1]). --export([partition/0]). +-export([partitions/0]). %% gen_server callbacks -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, @@ -33,7 +33,7 @@ -define(SERVER, ?MODULE). -define(RABBIT_UP_RPC_TIMEOUT, 2000). --record(state, {monitors, partition}). +-record(state, {monitors, partitions}). %%---------------------------------------------------------------------------- @@ -53,7 +53,7 @@ -spec(notify_joined_cluster/0 :: () -> 'ok'). -spec(notify_left_cluster/1 :: (node()) -> 'ok'). --spec(partition/0 :: () -> consistent | {atom(), node()}). +-spec(partitions/0 :: () -> {node(), [{atom(), node()}]}). -endif. @@ -176,8 +176,8 @@ notify_left_cluster(Node) -> %% Server calls %%---------------------------------------------------------------------------- -partition() -> - gen_server:call(?SERVER, partition, infinity). +partitions() -> + gen_server:call(?SERVER, partitions, infinity). %%---------------------------------------------------------------------------- %% gen_server callbacks @@ -185,11 +185,11 @@ partition() -> init([]) -> {ok, _} = mnesia:subscribe(system), - {ok, #state{monitors = pmon:new(), - partition = none}}. + {ok, #state{monitors = pmon:new(), + partitions = []}}. -handle_call(partition, _From, State = #state{partition = Partition}) -> - {reply, {node(), Partition}, State}; +handle_call(partitions, _From, State = #state{partitions = Partitions}) -> + {reply, {node(), Partitions}, State}; handle_call(_Request, _From, State) -> {noreply, State}. @@ -238,9 +238,12 @@ handle_info({'DOWN', _MRef, process, {rabbit, Node}, _Reason}, ok = handle_dead_rabbit(Node), {noreply, State#state{monitors = pmon:erase({rabbit, Node}, Monitors)}}; -handle_info({mnesia_system_event, {inconsistent_database, Context, Node}}, - State) -> - {noreply, State#state{partition = {Context, Node}}}; +handle_info({mnesia_system_event, + {inconsistent_database, running_partitioned_network, Node}}, + State = #state{partitions = Partitions}) -> + Partitions1 = ordsets:to_list( + ordsets:add_element(Node, ordsets:from_list(Partitions))), + {noreply, State#state{partitions = Partitions1}}; handle_info(_Info, State) -> {noreply, State}. |