diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2013-03-26 16:49:15 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2013-03-26 16:49:15 +0000 |
commit | 81ef7e1ba1ad331d29d697dd1fadde6dc7fc6f01 (patch) | |
tree | 2b9674ba93687640ea6396684c3f0ffa30f7f269 | |
parent | 137e6b0568eef1603cdfc9921f906e85548ff79a (diff) | |
download | rabbitmq-server-81ef7e1ba1ad331d29d697dd1fadde6dc7fc6f01.tar.gz |
Figure out a global view of partitions.
-rw-r--r-- | src/rabbit_node_monitor.erl | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/rabbit_node_monitor.erl b/src/rabbit_node_monitor.erl index ca39440b..c2c81545 100644 --- a/src/rabbit_node_monitor.erl +++ b/src/rabbit_node_monitor.erl @@ -281,8 +281,10 @@ handle_info({mnesia_system_event, {noreply, State2#state{partitions = Partitions1}}; handle_info({autoheal_request_winner, Node}, - State = #state{autoheal = {wait_for_winner_reqs,[Node], Notify}}) -> + State = #state{autoheal = {wait_for_winner_reqs,[Node], Notify}, + partitions = Partitions}) -> %% TODO actually do something sensible to figure out who the winner is + AllPartitions = all_partitions(Partitions), Winner = self(), rabbit_log:info("Autoheal: winner is ~p~n", [Winner]), [{?MODULE, N} ! {autoheal_winner, Winner} || N <- Notify], @@ -453,6 +455,24 @@ autoheal_restart(Winner) -> rabbit:start() end). +%% We have our local understanding of what partitions exist; but we +%% only know which nodes we have been partitioned from, not which +%% nodes are partitioned from each other. +%% +%% Note that here we assume that partition information is +%% consistent. If it isn't, what can we do? +all_partitions(PartitionedWith) -> + All = rabbit_mnesia:cluster_nodes(all), + OurPartition = All -- PartitionedWith, + all_partitions([OurPartition], PartitionedWith, All). + +all_partitions(AllPartitions, [], _) -> + AllPartitions; +all_partitions(AllPartitions, [One | _] = ToDo, All) -> + {One, PartitionedFrom} = rpc:call(One, rabbit_node_monitor, partitions, []), + Partition = All -- PartitionedFrom, + all_partitions([Partition | AllPartitions], ToDo -- Partition, All). + handle_dead_rabbit_state(State = #state{partitions = Partitions, autoheal = Autoheal}) -> %% If we have been partitioned, and we are now in the only remaining |