插件错误导致 emqx crash

环境

  • EMQX 版本: 5.1.4
  • 操作系统版本:CentOS Linux release 7.9.2009 (Core)

问题

我开发了一个插件,安装成功了。启动失败,我知道哪一行有错误,但是在我还没来得及卸载插件的时候停电了。 emqx 就启动不起来了,启动的时候说我的插件错误。我进入 plugins 目录,删掉插件相关文件,依然如此。

日志

erlang.log.1

=====
===== LOGGING STARTED Thu Sep  7 00:49:03 UTC 2023
=====
Erlang/OTP 25 [erts-13.2.2] [emqx] [64-bit] [smp:4:4] [ds:4:4:8] [async-threads:4]

Listener ssl:default on 0.0.0.0:8883 started.
Listener tcp:core on 0.0.0.0:1884 started.
Listener tcp:default on 0.0.0.0:1883 started.
Listener ws:default on 0.0.0.0:8083 started.
Listener wss:default on 0.0.0.0:8084 started.
Listener ssl:default on 0.0.0.0:8883 stopped.
Listener tcp:core on 0.0.0.0:1884 stopped.
Listener tcp:default on 0.0.0.0:1883 stopped.
Listener ws:default on 0.0.0.0:8083 stopped.
Listener wss:default on 0.0.0.0:8084 stopped.
{"Kernel pid terminated",application_controller,"{application_start_failure,emqx_machine,{{shutdown,{failed_to_start_child,emqx_machine_boot,{'EXIT',{{failed_to_start_app,emqx_plugins,{emqx_plugins,{bad_return,{{emqx_plugins_app,start,[normal,[]]},{'EXIT',{#{errors => [{\"my_emqx_plugin-1.0.0\",{failed,\"start_plugins\"}}],function => fun emqx_plugins:do_ensure_started/1},[{emqx_plugins,for_plugins,1,[{file,\"emqx_plugins.erl\"},{line,823}]},{emqx_plugins_app,start,2,[{file,\"emqx_plugins_app.erl\"},{line,30}]},{application_master,start_it_old,4,[{file,\"application_master.erl\"},{line,293}]}]}}}}}},[{emqx_machine_boot,start_one_app,1,[{file,\"emqx_machine_boot.erl\"},{line,107}]},{lists,foreach_1,2,[{file,\"lists.erl\"},{line,1442}]},{emqx_machine_boot,ensure_apps_started,0,[{file,\"emqx_machine_boot.erl\"},{line,97}]},{emqx_machine_boot,post_boot,0,[{file,\"emqx_machine_boot.erl\"},{line,40}]},{supervisor,do_start_child_i,3,[{file,\"supervisor.erl\"},{line,414}]},{supervisor,do_start_child,2,[{file,\"supervisor.erl\"},{line,400}]},{supervisor,'-start_children/2-fun-0-',3,[{file,\"supervisor.erl\"},{line,384}]},{supervisor,children_map,4,[{file,\"supervisor.erl\"},{line,1250}]},{supervisor,init_children,2,[{file,\"supervisor.erl\"},{line,350}]},{gen_server,init_it,2,[{file,\"gen_server.erl\"},{line,851}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,814}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,240}]}]}}}},{emqx_machine_app,start,[normal,[]]}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,emqx_machine,{{shutdown,{failed_to_start_child,emqx_machine_boot,{'EXIT',{{failed_to_start_app,emqx_plugins,{emqx_plugins,{bad_return,{{emqx_plugins_app,start,[normal,[]]},{'EXIT',{#{errors => [{"my_emqx_plugin-1.0.0",{failed,"start_plugins"}}],function => fun emqx_plugins:do_ensure_started/1},[{emqx_plugins,for_plugins,1,[{file,"emqx_plugins.erl"},{line,823}]},{emqx_plugins_app,start,2,[{file,"emqx_plugins_app.erl"},{line,30}]},{application_master,start_it_old,4,[{file,"application_master.erl"},{line,293}]}]}}}}}},[{emqx_machine_boot,start_one_app,1,[{file,"emqx_machine_boot.erl"},{line,107}]},{lists,foreach_1,2,[{file,"lists.erl"},{line,1442}]},{emqx_machine_boot,ensure_apps_started,0,[{file,"emqx_machine_boot.erl"},{line,97}]},{emqx_machine_boot,post_boot,0,[{file,"emqx_machine_boot.erl"},{line,40}]},{supervisor,do_start_child_i,3,[{file,"supervisor.erl"},{line,414}]},{supervisor,do_start_child,2,[{file,"supervisor.erl"},{line,400}

crash 文件
erl_crash.dump.zip (595.4 KB)

我的插件是my_emqx_plugin,在日志中可通过这个关键词检索。

需要手动清理下 data/configs/cluster.hocon 中

plugins {
...
}

这部分的配置。然后再启动 emqx 试试

但无论怎么说插件的错误不应该导致 EMQX 无法启动。这是一个 BUG,我们记录一下,后面版本会修复

1 个赞