Erlang:stop/start 之后的失忆状态很奇怪 table

Erlang: mnesia weird table state after stop/start

这是我的代码的相关部分

 N = node(),

 %set MNesia dir
 application:set_env(mnesia, dir, "/var/mnesia/"),
 %dont check status here, OK if already exists
 %stop if running, can't create schema if it is
 mnesia:stop(),
 %erlang:display(mnesia:delete_schema([N])),
 mnesia:create_schema([N]),
 %start MNesia, assert it works
 ok = mnesia:start(), %start MNesia, bomb if alreay started, should not happen
 lager:info("Mnesia started"),

 %erlang:display(mnesia:delete_table(application)),
 case mnesia:create_table(application,  [{attributes, record_info(fields, application)}, {disc_copies, [N]}]) of
     {aborted,{already_exists,application}} ->
         lager:info("Application table already exists");
     {atomic,ok} -> 
         lager:info(io_lib:format("Created application table on ~s", [N]))
 end,

 erlang:display(mnesia:table_info(application, all)),

 {atomic, Apps} = mnesia:transaction(fun() -> mnesia:match_object(application, {application, '_', '_', '_', '_', '_', '_', '_'    , '_', '_'}, read) end),
 erlang:display(Apps),

当我第一次启动我的应用程序时,一切正常:

14:34:57.736 [info] Mnesia started
14:34:57.736 [info] Application mnesia started on node cdapbroker@6371550eb22c
[{access_mode,read_write},{active_replicas,['cdapbroker@6371550eb22c']},{all_nodes,['cdapbroker@6371550eb22c']},{arity,10},{attributes,[appname,apptype,namespace,healthcheckurl,metricsurl,url,connectionurl,serviceendpoints,creationtime]},{checkpoints,[]},{commit_work,[]},{cookie,{{1489761297736523772,-576460752303422911,1},'cdapbroker@6371550eb22c'}},{cstruct,{cstruct,application,set,[],['cdapbroker@6371550eb22c'],[],[],0,read_write,false,[],[],false,application,[appname,apptype,namespace,healthcheckurl,metricsurl,url,connectionurl,serviceendpoints,creationtime],[],[],[],{{1489761297736523772,-576460752303422911,1},'cdapbroker@6371550eb22c'},{{2,0},[]}}},{disc_copies,['cdapbroker@6371550eb22c']},{disc_only_copies,[]},{external_copies,[]},{frag_properties,[]},{index,[]},{index_info,{index,set,[]}},{load_by_force,false},{load_node,'cdapbroker@6371550eb22c'},{load_order,0},{load_reason,{dumper,create_table}},{local_content,false},{majority,false},{master_nodes,[]},{memory,298},{ram_copies,[]},{record_name,application},{record_validation,{application,10,set}},{size,0},{snmp,[]},{storage_properties,[]},{storage_type,disc_copies},{subscribers,[]},{type,set},{user_properties,[]},{version,{{2,0},[]}},{where_to_commit,[{'cdapbroker@6371550eb22c',disc_copies}]},{where_to_read,'cdapbroker@6371550eb22c'},{where_to_wlock,{['cdapbroker@6371550eb22c'],false}},{where_to_write,['cdapbroker@6371550eb22c']},{wild_pattern,{application,'_','_','_','_','_','_','_','_','_'}}]
14:34:57.802 [info] Created application table on cdapbroker@6371550eb22c
[]

当我停止然后再次启动我的应用程序时,它 显示应用程序 table 详细信息 但在下一行 声称它没有'不存在!

14:36:44.168 [info] Mnesia started
14:36:44.168 [info] Application mnesia started on node cdapbroker@6371550eb22c
[{access_mode,read_write},{active_replicas,[]},{all_nodes,['cdapbroker@6371550eb22c']},{arity,10},{attributes,[appname,apptype,namespace,healthcheckurl,metricsurl,url,connectionurl,serviceendpoints,creationtime]},{checkpoints,[]},{commit_work,[]},{cookie,{{1489761297736523772,-576460752303422911,1},'cdapbroker@6371550eb22c'}},{cstruct,{cstruct,application,set,[],['cdapbroker@6371550eb22c'],[],[],0,read_write,false,[],[],false,application,[appname,apptype,namespace,healthcheckurl,metricsurl,url,connectionurl,serviceendpoints,creationtime],[],[],[],{{1489761297736523772,-576460752303422911,1},'cdapbroker@6371550eb22c'},{{2,0},[]}}},{disc_copies,['cdapbroker@6371550eb22c']},{disc_only_copies,[]},{external_copies,[]},{frag_properties,[]},{index,[]},{index_info,{index,set,[]}},{load_by_force,false},{load_node,unknown},{load_order,0},{load_reason,unknown},{local_content,false},{majority,false},{master_nodes,[]},{memory,undefined},{ram_copies,[]},{record_name,application},{record_validation,{application,10,set}},{size,undefined},{snmp,[]},{storage_properties,[]},{storage_type,disc_copies},{subscribers,[]},{type,set},{user_properties,[]},{version,{{2,0},[]}},{where_to_commit,[]},{where_to_read,nowhere},{where_to_write,[]},{wild_pattern,{application,'_','_','_','_','_','_','_','_','_'}}]
14:36:44.169 [info] Application table already exists
14:36:44.178 [error]
Error Stacktrace:
application_master:start_it_old/4 line 273
cdapbroker_app:start/2 line 65
error:{badmatch,{aborted,{no_exists,application}}}
14:36:44.179 [error] CRASH REPORT Process <0.145.0> with 0 neighbours exited with reason: {badmatch,{aborted,{no_exists,application}}} in application_master:init/4 line 134
14:36:44.179 [info] Application cdapbroker exited with reason: {badmatch,{aborted,{no_exists,application}}}

Eshell V8.2.1(用^G中止)

我试图让我的 table 在停止启动后继续存在,但我不明白以上内容。

这是一个计时问题。我认为 Mnesia 错误可能更具体..

我不得不补充:

ok = mnesia:wait_for_tables([application], 30000),

我想当 table 创建时(第一次启动时)table 立即可用,但在 stop/start 之后它不是 "ready yet"。