进程死亡原因调查:被杀?
原创文章,转载请注明: 转载自系统技术非业余研究
本文链接地址: 进程死亡原因调查:被杀?
最近MySQL平台化系统都是用热升级来更新的,在线上的日志发现类似的crashlog:
2013-07-24 23:54:06 =ERROR REPORT====
** Generic server <0.31760.980> terminating
** Last message in was {‘EXIT’,<0.29814.980>,killed}
** When Server state == {state,”app873″,false,172683,33,<<"app873">>,<0.29814.980>,ump_proxy_session,1,[59,32,204,78,86,208,242,122,240,207,269,79,80],[],2,true,<<>>,0,0,{conn_info,{10,246,161,112},10145,”app873″,”8813684fc05fb6cd”},<0.31762.980>,1,{conn_info,{172,18,134,8},10085,”app873″,”8813684fc05fb6cd”},ump_proxy_cherly_server,<0.31763.980>,1,undefined,<<>>,false,true,[],{dict,2,16,16,8,80,48,{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},{{[],[[{session,names},103,98,107]],[],[],[],[],[],[],[[{session,”character_set_results”},78,85,76,76]],[],[],[],[],[],[],[]}}},1,0,0,0,0,0,200,1374681206757732}
** Reason for termination ==
** killed
其中Reason是killed, 有点困扰。
我们知道在热升级的时候会purge用旧代码的进程, purge的时候发现有必要就会exit(P, kill)让进程死亡,但是怎么kill变成了killed呢?
我们看下release_handler和code的代码,验证我们的判断:
%%release_handler_1.erl eval({purge, Modules}, EvalState) -> % Now, if there are any processes still executing old code, OR % if some new processes started after suspend but before load, % these are killed. lists:foreach(fun(Mod) -> code:purge(Mod) end, Modules), EvalState; %%code_server.erl do_purge([P|Ps], Mod, Purged) -> case erlang:check_process_code(P, Mod) of true -> Ref = erlang:monitor(process, P), exit(P, kill), receive {'DOWN',Ref,process,_Pid,_} -> ok end, do_purge(Ps, Mod, true); false -> do_purge(Ps, Mod, Purged) end;
release_handler最终确实是调用了exit(P, kill)杀人,可是为什么对端收到killed死因呢?
再深入调查下原因,我们知道exit是虚拟机内部的实现,简单的grep下killed就可以看到send_exit_signal这个执行函数:
Read more…
Post Footer automatically generated by wp-posturl plugin for wordpress.
Recent Comments