summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2012-08-10 13:26:37 +0100
committerMatthias Radestock <matthias@rabbitmq.com>2012-08-10 13:26:37 +0100
commitb3940f5f7849d5dbb0cebd5dff91a69d3c84df7b (patch)
treef09f7fce6ff722f20924ee72b74ce4b7b71c29e4
parentc5079b2cfdea029f5d574d2d88a22af795fb924f (diff)
downloadrabbitmq-server-b3940f5f7849d5dbb0cebd5dff91a69d3c84df7b.tar.gz
just connect from all (visible) nodes instead
That way we don't rely on our current (possibly imperfect) knowledge of what the node was clustered with in mnesia. This is safe because, as per the comment, only mnesia cluster nodes should be part of the erlang distributed system. Note that rabbitmqctl et al run as *hidden* nodes.
-rw-r--r--src/rabbit_mnesia.erl21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl
index a92a92bc..5be23a88 100644
--- a/src/rabbit_mnesia.erl
+++ b/src/rabbit_mnesia.erl
@@ -738,14 +738,9 @@ reset(Force) ->
false -> ok
end,
Node = node(),
- ConfigNodes = read_cluster_nodes_config(),
case Force of
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]);
+ ok;
false ->
ensure_mnesia_dir(),
start_mnesia(),
@@ -753,7 +748,7 @@ reset(Force) ->
try
%% Force=true here so that reset still works when clustered
%% with a node which is down
- ok = init_db(ConfigNodes, true),
+ ok = init_db(read_cluster_nodes_config(), true),
{all_clustered_nodes() -- [Node],
running_clustered_nodes() -- [Node]}
after
@@ -761,19 +756,17 @@ reset(Force) ->
end,
leave_cluster(Nodes, RunningNodes),
rabbit_misc:ensure_ok(mnesia:delete_schema([Node]),
- cannot_delete_schema),
- disconnect_nodes(Nodes)
+ cannot_delete_schema)
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