summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_mnesia.erl37
1 files changed, 16 insertions, 21 deletions
diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl
index 8a1f31858d..244b880fc6 100644
--- a/src/rabbit_mnesia.erl
+++ b/src/rabbit_mnesia.erl
@@ -259,13 +259,9 @@ delete_cluster_nodes_config() ->
%% standalone disk node, or disk or ram node connected to the
%% specified cluster nodes.
init_db(ClusterNodes) ->
- WasDiskNode = mnesia:system_info(use_dir),
- IsDiskNode = ClusterNodes == [] orelse
- lists:member(node(), ClusterNodes),
- ExtraNodes = ClusterNodes -- [node()],
- case mnesia:change_config(extra_db_nodes, ExtraNodes) of
+ case mnesia:change_config(extra_db_nodes, ClusterNodes -- [node()]) of
{ok, []} ->
- case WasDiskNode of
+ case mnesia:system_info(use_dir) of
true ->
case check_schema_integrity() of
ok ->
@@ -285,14 +281,15 @@ init_db(ClusterNodes) ->
ok = create_schema()
end;
{ok, [_|_]} ->
- TableCopyType = case IsDiskNode of
- true -> disc;
- false -> ram
- end,
+ IsDiskNode = ClusterNodes == [] orelse
+ lists:member(node(), ClusterNodes),
ok = wait_for_replicated_tables(),
ok = create_local_table_copy(schema, disc_copies),
ok = create_local_non_replicated_table_copies(disc),
- ok = create_local_replicated_table_copies(TableCopyType);
+ ok = create_local_replicated_table_copies(case IsDiskNode of
+ true -> disc;
+ false -> ram
+ end);
{error, Reason} ->
%% one reason we may end up here is if we try to join
%% nodes together that are currently running standalone or
@@ -343,6 +340,12 @@ create_tables() ->
table_definitions()),
ok.
+table_has_copy_type(TabDef, DiscType) ->
+ case lists:keysearch(DiscType, 1, TabDef) of
+ false -> false;
+ {value, {DiscType, List}} -> lists:member(node(), List)
+ end.
+
create_local_replicated_table_copies(Type) ->
create_local_table_copies(Type, replicated_table_definitions()).
@@ -352,16 +355,8 @@ create_local_non_replicated_table_copies(Type) ->
create_local_table_copies(Type, TableDefinitions) ->
lists:foreach(
fun({Tab, TabDef}) ->
- Fun = fun(DiscType) ->
- case lists:keysearch(DiscType, 1, TabDef) of
- false ->
- false;
- {value, {DiscType, List}} ->
- lists:member(node(), List)
- end
- end,
- HasDiscCopies = Fun(disc_copies),
- HasDiscOnlyCopies = Fun(disc_only_copies),
+ HasDiscCopies = table_has_copy_type(TabDef, disc_copies),
+ HasDiscOnlyCopies = table_has_copy_type(TabDef, disc_only_copies),
StorageType =
case Type of
disc ->