inaka / worker_pool

Erlang worker pool
https://hex.pm/packages/worker_pool
Apache License 2.0
276 stars 80 forks source link

wpool fails to handle temporarily dead workers #94

Closed ElectronicRU closed 7 years ago

ElectronicRU commented 7 years ago

In particular, the following code:

  case erlang:process_info(erlang:whereis(Worker), message_queue_len) of
    {message_queue_len, 0} -> Worker;
    {message_queue_len, L} ->
      min_message_queue(Checked + 1, next_wpool(Wpool), [{L, Worker} | Found])
  end.

in wpool_pool.erl fails if the worker is restarting, whether for valid or invalid reasons.

The dead workers aren't handled in any strategy, though; they're just assumed to be always alive. That's a shame since {stop, ...} tuples appear to be handled on the surface.

elbrujohalcon commented 7 years ago

Fair point. wpool should deal with unefined being the result of erlang:whereis/1. Thanks for spotting this, @ElectronicRU :)

ElectronicRU commented 7 years ago

https://github.com/inaka/worker_pool/blob/master/src/wpool_pool.erl#L223 this is another potentially problematic place