This commit is contained in:
@@ -62,6 +62,22 @@ handle_call(init_tables, _From, State) ->
|
||||
ok = join_cluster(ExtraNodes)
|
||||
end,
|
||||
lists:foreach(fun create_table/1, ?TABLES),
|
||||
% Принудительное создание node_metric на каждом узле
|
||||
case mnesia:create_table(node_metric, [
|
||||
{disc_copies, [node()]}, % хранить на диске
|
||||
{local_content, true}, % не реплицировать
|
||||
{attributes, record_info(fields, node_metric)}
|
||||
]) of
|
||||
{atomic, ok} -> ok;
|
||||
{aborted, {already_exists, node_metric}} -> ok;
|
||||
_ -> ok
|
||||
end,
|
||||
% ГАРАНТИРУЕМ, что узел имеет локальную копию node_metric (критично для присоединяющихся узлов)
|
||||
case lists:member(node(), mnesia:table_info(node_metric, disc_copies) ++
|
||||
mnesia:table_info(node_metric, ram_copies)) of
|
||||
false -> mnesia:add_table_copy(node_metric, node(), disc_copies);
|
||||
true -> ok
|
||||
end,
|
||||
ok = create_indices(),
|
||||
ok = stats_collector:subscribe(),
|
||||
ok = start_cleanup_timer(),
|
||||
@@ -223,7 +239,7 @@ table_opts(schema_migration) -> [{disc_copies, [node()]}, {attributes, record_in
|
||||
table_opts(session) -> [{ram_copies, [node()]}, {attributes, record_info(fields, session)}];
|
||||
table_opts(verification) -> [{ram_copies, [node()]}, {attributes, record_info(fields, verification)}];
|
||||
table_opts(admin_session) -> [{ram_copies, [node()]}, {attributes, record_info(fields, admin_session)}];
|
||||
table_opts(node_metric) -> [{ram_copies, [node()]}, {local_content, true}, {attributes, record_info(fields, node_metric)}].
|
||||
table_opts(node_metric) -> [{disc_copies, [node()]}, {local_content, true}, {attributes, record_info(fields, node_metric)}].
|
||||
|
||||
%% ===================================================================
|
||||
%% Индексы
|
||||
|
||||
Reference in New Issue
Block a user