我在docker容器中构建了一个erlang应用程序。
我的数据目录作为docker卷连接。
我正在使用:
application:set_env(mnesia, schema_location, disc),
和{disc_copies, Nodes}
。
当我用:
重启应用时docker-composer stop myapp && docker-composer up myapp
一切正常,但当我完全关闭时:
sudo systemctl restart docker
docker-composer up -d
Mnesia停止识别我的数据。当我重新启动计算机时也是如此。
基本上(在此之后"硬"重启)Mnesia正常启动但当我尝试从中读取任何内容时,我收到错误:
{running_method,getTasksByProjectId}
terminate reason: {aborted,{no_exists,mtm_tasks}}
terminate reason: {{aborted,{no_exists,mtm_tasks}},
{gen_server,call,
[{global,tasks_da_serv},
{get_tasks_by_project_id,
"j1xvqric-2oj2q784xieccowg8880"}]}}
=ERROR REPORT==== 8-Jun-2017::10:29:04 ===
** Generic server tasks_da_serv terminating
** Last message in was {get_tasks_by_project_id,
"j1xvqric-2oj2q784xieccowg8880"}
** When Server state == {tasks_da_state}
** Reason for termination ==
** {{aborted,{no_exists,mtm_tasks}},
[{mnesia,wrap_trans,6,[{file,"mnesia.erl"},{line,404}]},
{tasks_logic,get_tasks_by_project_id,1,
[{file,"/release/_build/default/lib/tasks/src/tasks_logic.erl"},
{line,70}]},
{tasks_da_serv,handle_call,3,
[{file,"/release/_build/default/lib/tasks/src/tasks_da_serv.erl"},
{line,52}]},
{gen_server,try_handle_call,4,[{file,"gen_server.erl"},{line,615}]},
{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,647}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}
Starting {global,tasks_da_serv} (<0.492.0>)
Starting {global,tasks_manager_serv} (<0.497.0>)
=ERROR REPORT==== 8-Jun-2017::10:29:04 ===
** Generic server tasks_manager_serv terminating
** Last message in was {{'basic.deliver',
<<"amq.ctag-pt-OySikx5BShVLRASvIPw">>,1,false,
<<>>,<<"tasks">>},
{amqp_msg,
{'P_basic',undefined,undefined,[],undefined,
undefined,undefined,undefined,undefined,
undefined,undefined,undefined,undefined,
undefined,undefined},
<<"{\"correlationId\":\"j3oa5b84-pcxn9ld6mswsck8kw48\",\"replyTo\":\"amq.gen-8h_kLqz4sHB-qjJ2cj8Y6w\",\"method\":\"getTasksByProjectId\",\"params\":{\"projectId\":\"j1xvqric-2oj2q784xieccowg8880\"}}">>}}
** When Server state == {tasks_manager_state,<0.481.0>,<0.490.0>}
** Reason for termination ==
** {{{aborted,{no_exists,mtm_tasks}},
{gen_server,call,
[{global,tasks_da_serv},
{get_tasks_by_project_id,"j1xvqric-2oj2q784xieccowg8880"}]}},
[{gen_server,call,2,[{file,"gen_server.erl"},{line,204}]},
{tasks_manager_logic,handle_message,2,
[{file,"/release/_build/default/lib/tasks/src/tasks_manager_logic.erl"},
{line,7}]},
{tasks_manager_serv,handle_info,2,
[{file,"/release/_build/default/lib/tasks/src/tasks_manager_serv.erl"},
{line,45}]},
{gen_server,try_dispatch,4,[{file,"gen_server.erl"},{line,601}]},
{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,667}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}
此时,再次使其工作的唯一方法是从docker卷中删除数据。
答案 0 :(得分:3)
我已经弄清楚了。问题是docker正在为容器分配自定义主机名,而Mnesia光盘副本显然是绑定到主机名。 现在我在docker-compose.yaml文件中修复了主机名:
version: '2'
services:
myapp:
build: './myapp'
hostname: 'myapp'
volumes:
...
现在可以在不丢失数据的情况下重新启动它。