devinus/poolboy

exception exit: timeout in gen_server:call

ostinelli opened this issue · 1 comments

All,
We are experiencing the following error when calling a transaction as per the README:

equery(PoolName, Stmt, Params) ->
    poolboy:transaction(PoolName, fun(Worker) ->
        gen_server:call(Worker, {equery, Stmt, Params})
    end).
** exception exit: {timeout,{gen_server,call,
                                        [keys_db,{checkout,#Ref<0.0.1.156295>,true},5000]}}
     in function  gen_server:call/3 (gen_server.erl, line 212)
     in call from poolboy:checkout/3 (/home/ubuntu/workspace/myapp/_build/default/lib/poolboy/src/poolboy.erl, line 55)
     in call from poolboy:transaction/3 (/home/ubuntu/workspace/myapp/_build/default/lib/poolboy/src/poolboy.erl, line 74)

The process queue keeps on increasing, and I can see the following:

3> erlang:process_info(whereis(keys_db)).  
[{registered_name,keys_db},
 {current_function,{gen,do_call,4}},
 {initial_call,{proc_lib,init_p,5}},
 {status,waiting},
 {message_queue_len,11906},
 {messages,[{'$gen_cast',{cancel_waiting,#Ref<0.0.1.138090>}},
            {'$gen_call',{<0.15224.0>,#Ref<0.0.1.139621>},
                         {checkout,#Ref<0.0.1.139620>,true}},
            {'$gen_call',{<0.15139.0>,#Ref<0.0.1.139649>},
                         {checkout,#Ref<0.0.1.139648>,true}},
            {'$gen_cast',{cancel_waiting,#Ref<0.0.1.138159>}},
            {'$gen_cast',{cancel_waiting,#Ref<0.0.1.138175>}},
            {'$gen_cast',{cancel_waiting,#Ref<0.0.1.138232>}},
            {'$gen_cast',{cancel_waiting,#Ref<0.0.1.138252>}},
            {'$gen_cast',{cancel_waiting,#Ref<0.0.1.138261>}},
            {'$gen_cast',{cancel_waiting,#Ref<0.0.1.138286>}},
            {'$gen_call',{<0.15235.0>,#Ref<0.0.1.139774>},
                         {checkout,#Ref<0.0.1.139773>,true}},
            {'$gen_cast',{cancel_waiting,#Ref<0.0.2.77777>}},
            {'$gen_cast',{cancel_waiting,#Ref<0.0.1.138318>}},
            {'$gen_cast',{cancel_waiting,#Ref<0.0.1.138336>}},
            {'$gen_call',{<0.15233.0>,#Ref<0.0.1.139816>},
                         {checkout,#Ref<0.0.1.139815>,true}},
            {'$gen_call',{<0.15245.0>,#Ref<0.0.1.139854>},
                         {checkout,#Ref<0.0.1.139853>,true}},
            {'$gen_call',{<0.15237.0>,#Ref<0.0.2.78173>},
                         {checkout,#Ref<0.0.2.78172>,...}},
            {'$gen_cast',{cancel_waiting,#Ref<0.0.1.138407>}},
            {'$gen_call',{<0.15228.0>,...},{...}},
            {'$gen_call',{...},...},
            {'$gen_call',...},
            {...}|...]},
 {links,[<0.714.1>,<0.817.1>,<0.947.1>,<0.1015.1>,<0.1045.1>,
         <0.1048.1>,<0.1038.1>,<0.983.1>,<0.1002.1>,<0.962.1>,
         <0.877.1>,<0.909.1>,<0.938.1>,<0.892.1>,<0.849.1>,<0.866.1>,
         <0.832.1>,<0.765.1>,<0.789.1>,<0.804.1>|...]},
 {dictionary,[{'$initial_call',{poolboy,init,1}},
              {'$ancestors',[pgpool_sup,<0.673.0>]}]},
 {trap_exit,true},
 {error_handler,error_handler},
 {priority,normal},
 {group_leader,<0.672.0>},
 {total_heap_size,393326},
 {heap_size,196650},
 {stack_size,33},
 {reductions,14837255},
 {garbage_collection,[{max_heap_size,#{error_logger => true,
                                       kill => true,
                                       size => 0}},
                      {min_bin_vheap_size,46422},
                      {min_heap_size,233},
                      {fullsweep_after,10},
                      {minor_gcs,3}]},
 {suspending,[]}]

Do you have an insight of what may be going wrong? I see that the process status is waiting...

Thank you,
r.

Seems like an issue in flow control. What is the best way to know if there's an available worker, before calling a transaction?