2017-05-03 211 views
0
start(_Type, _Args) -> 
    case application:get_env(ebid, join_schema) of 
    undefined -> 
     mnesia:create_schema([node()]), 
     mnesia:start(), 
     initialize_tables(), 
     mnesia:wait_for_tables([<<set of tables>>], timer:minutes(5)); 
    {ok, Node} -> 
     pong = net_adm:ping(Node), 
     join_schema(Node), 
     mnesia:wait_for_tables([<<set of tables>>], timer:minutes(5)) 
end, 

join_schema(Node) -> 
case rpc:call('[email protected]', mnesia, change_config, [extra_db_nodes, [node()]]) of 
    {ok, _Result} -> 
     lists:foreach(fun(Tab) -> io:format("~p : ~p ~n",[Tab,timer:tc(mnesia,add_table_copy,[Tab, node(), ram_copies])]) end, mnesia:system_info(tables)); 
    {error, Reason} -> 
     mnesia:stop(), 
     mnesia:del_table_copy(schema, node()), 
     error_logger:error_msg("Failed to join schema: ~p~n", [Reason]), 
     error(Reason) 
end. 

有没有一种方法可以调试为什么join_schema需要很长时间? 我们共有10个表格来代替“表格集合”,并且整体大小为< 400 MBMnesia RPC呼叫花费太长时间

只有在join_schema完成后,工作人员才会加入集群。

主节点工作正常,并有mnesia了。

+0

尝试启动4个节点一次连接到主表 –

回答

1

终于能够解决问题了。问题是我们根据负载情况对工作人员遵循EC2的自动扩展策略。在一段时间(1年以上),我们有很多这样的工作者进出,因此主表extra_db_nodes大大扩展了。

重新启动主人解决了问题。

相关问题