diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2012-08-11 07:41:00 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2012-08-11 07:41:00 +0100 |
commit | 10cda2191282649534493f8dc8b80da65bdbf436 (patch) | |
tree | d95f2b13a56a82512cb55b13c23773082deb9bbe | |
parent | b3940f5f7849d5dbb0cebd5dff91a69d3c84df7b (diff) | |
download | rabbitmq-server-10cda2191282649534493f8dc8b80da65bdbf436.tar.gz |
be a bit more selective about which nodes we disconnect from
...in case we one day relax the restriction that all erlang
distribution nodes must be part of the same cluster.
- force=false -> all nodes we are clustered with
- force=true -> all nodes we are connected to
Forceful resets are employed to cope with various conditions in which
the cluster has gotten into a bad state, so its best not to rely on
mnesia's knowledge of the cluster state.
Also:
- some drive-by refactoring
- nodes() never includes node(), so no need to filter the former
-rw-r--r-- | src/rabbit_mnesia.erl | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl index 5be23a88..61b4054a 100644 --- a/src/rabbit_mnesia.erl +++ b/src/rabbit_mnesia.erl @@ -732,15 +732,14 @@ reset(Force) -> end]), ensure_mnesia_not_running(), case not Force andalso is_clustered() andalso - is_only_disc_node(node(), false) + is_only_disc_node(node(), false) of true -> log_both("no other disc nodes running"); false -> ok end, - Node = node(), case Force of true -> - ok; + disconnect_nodes(nodes()); false -> ensure_mnesia_dir(), start_mnesia(), @@ -749,24 +748,26 @@ reset(Force) -> %% Force=true here so that reset still works when clustered %% with a node which is down ok = init_db(read_cluster_nodes_config(), true), - {all_clustered_nodes() -- [Node], - running_clustered_nodes() -- [Node]} + {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) + rabbit_misc:ensure_ok(mnesia:delete_schema([node()]), + 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() -- [Node]], 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 |