diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2012-08-10 13:13:15 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2012-08-10 13:13:15 +0100 |
commit | c5079b2cfdea029f5d574d2d88a22af795fb924f (patch) | |
tree | 5859a2387e7b25949a196329d3c77466f075e5cf | |
parent | 26461122d432be23aabed9a9b67019ea652d2071 (diff) | |
download | rabbitmq-server-c5079b2cfdea029f5d574d2d88a22af795fb924f.tar.gz |
make unclustering work for ram nodes
- leave the cluster properly when force=false
- disconnect from nodes we know about when force=true
-rw-r--r-- | src/rabbit_mnesia.erl | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl index 5a971246..a92a92bc 100644 --- a/src/rabbit_mnesia.erl +++ b/src/rabbit_mnesia.erl @@ -738,34 +738,42 @@ reset(Force) -> false -> ok end, Node = node(), - Nodes = all_clustered_nodes() -- [Node], + ConfigNodes = read_cluster_nodes_config(), case Force of - true -> ok; + true -> + %% If Node is a ram node, all_clustered_nodes() returns + %% just that when mnesia isn't running. So we also include + %% the the next best thing - the nodes from the config. + disconnect_nodes( + lists:usort(all_clustered_nodes() ++ ConfigNodes) -- [Node]); false -> ensure_mnesia_dir(), start_mnesia(), - RunningNodes = + {Nodes, RunningNodes} = try %% Force=true here so that reset still works when clustered %% with a node which is down - ok = init_db(read_cluster_nodes_config(), true), - running_clustered_nodes() -- [Node] + ok = init_db(ConfigNodes, true), + {all_clustered_nodes() -- [Node], + running_clustered_nodes() -- [Node]} after stop_mnesia() end, leave_cluster(Nodes, RunningNodes), rabbit_misc:ensure_ok(mnesia:delete_schema([Node]), - cannot_delete_schema) + cannot_delete_schema), + disconnect_nodes(Nodes) end, - %% We need to make sure that we don't end up in a distributed - %% Erlang system with nodes while not being in an Mnesia cluster - %% with them. We don't handle that well. - [erlang:disconnect_node(N) || N <- Nodes], ok = delete_cluster_nodes_config(), %% remove persisted messages and any other garbage we find ok = rabbit_file:recursive_delete(filelib:wildcard(dir() ++ "/*")), ok. +%% We need to make sure that we don't end up in a distributed Erlang +%% system with nodes while not being in an Mnesia cluster with +%% them. We don't handle that well. +disconnect_nodes(Nodes) -> [erlang:disconnect_node(N) || N <- Nodes]. + leave_cluster([], _) -> ok; leave_cluster(Nodes, RunningNodes) -> %% find at least one running cluster node and instruct it to |