无法解释此 Eshell 崩溃报告

问题描述 投票:0回答:1

我正在尝试使用 ecpool 库 来池化 Mongo 数据库连接。

我的主管的 init 看起来像我在第一个代码片段中添加的内容。

mongo_client
是我用来设置与 Mongo 实例的连接的模块。

无论输入如何,我在运行时都会收到

undef
错误,但我在解释崩溃报告时遇到困难。任何提示将不胜感激。

init([]) ->
    PoolSize = 10,
    Urls = ["localhost:27017"],
    Database = "test",
    Username = "test",
    Password = "test",
    Type = single,

    % Define the worker arguments
    WorkerArgs = [
        {hosts, Urls},
        {database, Database},
        {login, Username},
        {password, Password},
        {type, Type}
    ],

    PoolOptions = [
        {pool_size, PoolSize},
        {auto_reconnect, 1},
        {options, []},
        {worker_options, WorkerArgs}
    ],

    PoolSpec = ecpool:pool_spec(?APP, ?APP, mongo_client, PoolOptions),

    {ok, {{one_for_all, 10, 100}, [PoolSpec]}}. 

崩溃报告:

Eshell V15.0.1 (press Ctrl+G to abort, type help(). for help)
=CRASH REPORT==== 29-Aug-2024::16:19:21.153000 ===
  crasher:
    initial call: ecpool_worker:init/1
    pid: <0.253.0>
    registered_name: []
    exception exit: undef
      in function  gen_server:init_it/6 (gen_server.erl, line 2038)
    ancestors: [<0.252.0>,<0.250.0>,mongo_app_sup,<0.248.0>]
    message_queue_len: 0
    messages: []
    links: [<0.252.0>]
    dictionary: []
    trap_exit: true
    status: running
    heap_size: 233
    stack_size: 29
    reductions: 103
  neighbours:

=SUPERVISOR REPORT==== 29-Aug-2024::16:19:21.158000 ===
    supervisor: {<0.252.0>,ecpool_worker_sup}
    errorContext: start_error
    reason: undef
    offender: [{pid,undefined},
               {id,{worker,1}},
               {mfargs,
                   {ecpool_worker,start_link,
                       [mongo_app,1,mongo_client,
                        [{pool_size,10},
                         {auto_reconnect,1},
                         {options,[]},
                         {worker_options,
                             [{hosts,["localhost:27017"]},
                              {database,"test"},
                              {login,"test"},
                              {password,"test"},
                              {type,single}]}]]}},
               {restart_type,transient},
               {significant,false},
               {shutdown,5000},
               {child_type,worker}]

=SUPERVISOR REPORT==== 29-Aug-2024::16:19:21.158000 ===
    supervisor: {<0.250.0>,ecpool_pool_sup}
    errorContext: start_error
    reason: {shutdown,{failed_to_start_child,{worker,1},undef}}
    offender: [{pid,undefined},
               {id,worker_sup},
               {mfargs,
                   {ecpool_worker_sup,start_link,
                       [mongo_app,mongo_client,
                        [{pool_size,10},
                         {auto_reconnect,1},
                         {options,[]},
                         {worker_options,
                             [{hosts,["localhost:27017"]},
                              {database,"test"},
                              {login,"test"},
                              {password,"test"},
                              {type,single}]}]]}},
               {restart_type,transient},
               {significant,false},
               {shutdown,infinity},
               {child_type,supervisor}]

=SUPERVISOR REPORT==== 29-Aug-2024::16:19:21.158000 ===
    supervisor: {local,mongo_app_sup}
    errorContext: start_error
    reason: {shutdown,
                {failed_to_start_child,worker_sup,
                    {shutdown,{failed_to_start_child,{worker,1},undef}}}}
    offender: [{pid,undefined},
               {id,mongo_app},
               {mfargs,
                   {ecpool,start_pool,
                       [mongo_app,mongo_client,
                        [{pool_size,10},
                         {auto_reconnect,1},
                         {options,[]},
                         {worker_options,
                             [{hosts,["localhost:27017"]},
                              {database,"test"},
                              {login,"test"},
                              {password,"test"},
                              {type,single}]}]]}},
               {restart_type,permanent},
               {significant,false},
               {shutdown,5000},
               {child_type,supervisor}]

=INFO REPORT==== 29-Aug-2024::16:19:21.158000 ===
    application: mongo_app
    exited: {{shutdown,
                 {failed_to_start_child,mongo_app,
                     {shutdown,
                         {failed_to_start_child,worker_sup,
                             {shutdown,
                                 {failed_to_start_child,{worker,1},undef}}}}}},
             {mongo_app_app,start,[normal,[]]}}
    type: temporary

=CRASH REPORT==== 29-Aug-2024::16:19:21.158000 ===
  crasher:
    initial call: application_master:init/3
    pid: <0.247.0>
    registered_name: []
    exception exit: {{shutdown,
                      {failed_to_start_child,mongo_app,
                       {shutdown,
                        {failed_to_start_child,worker_sup,
                         {shutdown,
                          {failed_to_start_child,{worker,1},undef}}}}}},
                     {mongo_app_app,start,[normal,[]]}}
      in function  application_master:init/3 (application_master.erl, line 143)
    ancestors: [application_controller,<0.10.0>]
    message_queue_len: 1
    messages: [{'EXIT',<0.248.0>,normal}]
    links: [<0.45.0>]
    dictionary: []
    trap_exit: true
    status: running
    heap_size: 376
    stack_size: 29
    reductions: 70
  neighbours:

=INFO REPORT==== 29-Aug-2024::16:19:21.165000 ===
    application: ecpool
    exited: stopped
    type: temporary

=INFO REPORT==== 29-Aug-2024::16:19:21.171000 ===
    application: gproc
    exited: stopped
    type: temporary

=INFO REPORT==== 29-Aug-2024::16:19:21.176000 ===
    application: mongodb
    exited: stopped
    type: temporary

=INFO REPORT==== 29-Aug-2024::16:19:21.176000 ===
    application: pbkdf2
    exited: stopped
    type: temporary

=INFO REPORT==== 29-Aug-2024::16:19:21.176000 ===
    application: poolboy
    exited: stopped
    type: temporary

=INFO REPORT==== 29-Aug-2024::16:19:21.176000 ===
    application: bson
    exited: stopped
    type: temporary

===> Booted sasl
===> Failed to boot mongo_app for reason {{shutdown,
                                           {failed_to_start_child,mongo_app,
                                            {shutdown,
                                             {failed_to_start_child,
                                              worker_sup,
                                              {shutdown,
                                               {failed_to_start_child,
                                                {worker,1},
                                                undef}}}}}},
                                          {mongo_app_app,start,[normal,[]]}}
erlang erlang-otp
1个回答
0
投票

很奇怪。在我看来,就像

ecpool_worker_sup
开始一样,但不知何故,
ecpool_worker
init
函数得到的参数太少了。它应该得到
[Pool, Id, Mod, Opts, InitialConnectResultReceiverAlias]
,但在错误消息中我只看到
[mongo_app,1,mongo_client,[{pool_size,10},...]]
,所以
undef
可能指的是没有找到
init/4
,因为
ecpool_worker
导出
init/5

是否您的

ecpool_worker_sup
ecpool_worker
版本不匹配?也许只是旧的 .beam 文件。

© www.soinside.com 2019 - 2024. All rights reserved.