diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2012-02-01 18:22:11 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2012-02-01 18:22:11 +0000 |
commit | 5009215bda0119e9fb05efac22f4cae3533dcab6 (patch) | |
tree | 145c799b99a80bdd61607a76adc30172f2f2beaf | |
parent | 1df635925ca8623633b1f0a2256543b47ca14e1e (diff) | |
download | rabbitmq-server-bug24413.tar.gz |
Quick hack at rabbitmqctl force_cluster_forget. Appears to work.bug24413
-rw-r--r-- | src/rabbit_control.erl | 6 | ||||
-rw-r--r-- | src/rabbit_mnesia.erl | 17 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl index 22b57b1a..02b27821 100644 --- a/src/rabbit_control.erl +++ b/src/rabbit_control.erl @@ -212,6 +212,12 @@ action(force_cluster, Node, ClusterNodeSs, _Opts, Inform) -> [Node, ClusterNodes]), rpc_call(Node, rabbit_mnesia, force_cluster, [ClusterNodes]); +action(force_cluster_forget, Node, ClusterNodeSs, _Opts, Inform) -> + ClusterNodes = lists:map(fun list_to_atom/1, ClusterNodeSs), + Inform("Telling node ~p to forget ~p", + [Node, ClusterNodes]), + rpc_call(Node, rabbit_mnesia, cluster_forget, [ClusterNodes]); + action(wait, Node, [PidFile], _Opts, Inform) -> Inform("Waiting for ~p", [Node]), wait_for_application(Node, PidFile, Inform); diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl index bf997a6f..fb97ff0e 100644 --- a/src/rabbit_mnesia.erl +++ b/src/rabbit_mnesia.erl @@ -24,7 +24,7 @@ create_cluster_nodes_config/1, read_cluster_nodes_config/0, record_running_nodes/0, read_previously_running_nodes/0, delete_previously_running_nodes/0, running_nodes_filename/0, - is_disc_node/0, on_node_down/1, on_node_up/1]). + is_disc_node/0, on_node_down/1, on_node_up/1, cluster_forget/1]). -export([table_names/0]). @@ -183,6 +183,21 @@ cluster(ClusterNodes, Force) -> ok. +cluster_forget(Nodes) -> + rabbit_misc:local_info_msg("Forgetting ~p forcefully~n", [Nodes]), + ensure_mnesia_not_running(), + ensure_mnesia_dir(), + + start_mnesia(), + try + [mnesia:force_load_table(T) || T <- rabbit_mnesia:table_names()], + [{atomic, ok} = mnesia:del_table_copy(schema, Node) || Node <- Nodes] + + after + stop_mnesia() + end, + ok. + %% return node to its virgin state, where it is not member of any %% cluster, has no cluster configuration, no local database, and no %% persisted messages |