summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexandru Scvortov <alexandru@rabbitmq.com>2011-08-03 12:48:04 +0100
committerAlexandru Scvortov <alexandru@rabbitmq.com>2011-08-03 12:48:04 +0100
commit1dfde164803eb95df86957f0e28a7a6cae2f892c (patch)
tree4be72e07c68cc52ed24f678ebf3f6715f2d5d42c /src
parent65fe27ce65b0c29e6d18fb35b1e1439842d64813 (diff)
downloadrabbitmq-server-git-1dfde164803eb95df86957f0e28a7a6cae2f892c.tar.gz
don't stop mnesia if it was already running
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_mnesia.erl21
-rw-r--r--src/rabbit_node_monitor.erl8
2 files changed, 14 insertions, 15 deletions
diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl
index 0dff7fa280..474b41367b 100644
--- a/src/rabbit_mnesia.erl
+++ b/src/rabbit_mnesia.erl
@@ -28,8 +28,6 @@
-export([table_names/0]).
--compile([export_all]).
-
%% create_tables/0 exported for helping embed RabbitMQ in or alongside
%% other mnesia-using Erlang applications, such as ejabberd
-export([create_tables/0]).
@@ -120,7 +118,8 @@ cluster(ClusterNodes, Force) ->
ensure_mnesia_not_running(),
ensure_mnesia_dir(),
- case {is_only_disc_node(node()), should_be_disc_node(ClusterNodes)} of
+ case {is_only_disc_node(node(), false),
+ should_be_disc_node(ClusterNodes)} of
{true, false} -> log_both("last disc node leaving cluster");
_ -> ok
end,
@@ -698,7 +697,7 @@ wait_for_tables(TableNames) ->
reset(Force) ->
ensure_mnesia_not_running(),
- case is_only_disc_node(node()) of
+ case is_only_disc_node(node(), false) of
true -> log_both("resetting only disc node");
false -> ok
end,
@@ -750,22 +749,22 @@ leave_cluster(Nodes, RunningNodes) ->
end.
on_node_down(Node) ->
- io:format("node down!!! ~p~n", [Node]),
- case is_only_disc_node(Node) of
+ case is_only_disc_node(Node, true) of
true -> log_both("last disc node went down");
false -> ok
end.
-is_only_disc_node(Node) ->
+is_only_disc_node(Node, _MnesiaRunning = true) ->
+ [Node] =:= nodes_of_type(disc_copies);
+is_only_disc_node(Node, false) ->
start_mnesia(),
- Nodes = nodes_of_type(disc_copies),
+ Res = is_only_disc_node(Node, true),
stop_mnesia(),
- [Node] =:= Nodes.
+ Res.
log_both(Warning) ->
io:format("Warning: ~s~n", [Warning]),
- %%error_logger:warning_msg("~s~n", [Warning]).
- ok.
+ error_logger:warning_msg("~s~n", [Warning]).
start_mnesia() ->
rabbit_misc:ensure_ok(mnesia:start(), cannot_start_mnesia),
diff --git a/src/rabbit_node_monitor.erl b/src/rabbit_node_monitor.erl
index bb93ab82ed..f82c831fd1 100644
--- a/src/rabbit_node_monitor.erl
+++ b/src/rabbit_node_monitor.erl
@@ -95,11 +95,11 @@ code_change(_OldVsn, State, _Extra) ->
%% TODO: This may turn out to be a performance hog when there are lots
%% of nodes. We really only need to execute some of these statements
-%% on *one* node, rather than all of them.
+%% on *one* node, rather than all of them. NOTE: This function will be
+%% executed *twice* if the other rabbit node is shut down cleanly
+%% (once for the rabbit_app going down and once for the node).
handle_dead_rabbit(Node) ->
ok = rabbit_networking:on_node_down(Node),
ok = rabbit_amqqueue:on_node_down(Node),
ok = rabbit_alarm:on_node_down(Node),
- rabbit_log:info("handling dead rabbit!~p~n", [Node]),
- %%ok = rabbit_mnesia:on_node_down(Node).
- ok.
+ ok = rabbit_mnesia:on_node_down(Node).