2017-05-03 205 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大大擴展了。

重新啓動主人解決了問題。