diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2013-04-08 15:56:18 +0100 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2013-04-08 15:56:18 +0100 |
commit | c9bac515bb06c2a4a1514baba21ccbca28f525ee (patch) | |
tree | c099beeffdcaed050afd2e2ba6c1d284643c2a94 | |
parent | 79ecab90cfaded68f596cf3783f907ffe8c106f2 (diff) | |
download | rabbitmq-server-c9bac515bb06c2a4a1514baba21ccbca28f525ee.tar.gz |
Deal with partial partitions.
-rw-r--r-- | src/rabbit_node_monitor.erl | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/rabbit_node_monitor.erl b/src/rabbit_node_monitor.erl index 7fd20f8c..07898d34 100644 --- a/src/rabbit_node_monitor.erl +++ b/src/rabbit_node_monitor.erl @@ -537,20 +537,26 @@ autoheal_restart(Winner) -> %% 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 - which it isn't. TODO fix this. 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). + Nodes = rabbit_mnesia:cluster_nodes(all), + Partitions = [{node(), PartitionedWith} | + [rpc:call(Node, rabbit_node_monitor, partitions, []) + || Node <- Nodes -- [node()]]], + all_partitions(Partitions, [Nodes]). + +all_partitions([], Partitions) -> + Partitions; +all_partitions([{Node, CantSee} | Rest], Partitions) -> + {[Containing], Others} = + lists:partition(fun (Part) -> lists:member(Node, Part) end, Partitions), + A = Containing -- CantSee, + B = Containing -- A, + Partitions1 = case {A, B} of + {[], _} -> Partitions; + {_, []} -> Partitions; + _ -> [A, B | Others] + end, + all_partitions(Rest, Partitions1). handle_dead_rabbit_state(Node, State = #state{partitions = Partitions, autoheal = Autoheal}) -> |