Thanks for your reply José.

I’m trapping the exits so I can make sure the connection gets closed if the 
worker is terminated for any reason.
https://github.com/devinus/poolboy/issues/35

When the worker dies, I expect that terminate will get called, which should 
then close the connection.

The connection doesn’t look to be another process, but a reference that is used 
as a key in the process dictionary to get the state of that connection. Inside 
that state we have the socket (Port). If the worker dies, it should take the 
port down with it.

I’m not using the Hackney pool because we want to parallelize the processing 
and building of responses on the worker. 

The Fix:

It looks like I was able to get it to stop leaking by manually closing the 
connection when an {:error, :closed} tuple is returned.

https://gist.github.com/ericgoodwin/0d7dcd9d0f43c75337dc43a5df0423b2#file-search-ex-L82

I was expecting that if the client returned {:error, :closed}, it would have 
closed the port, but it looks like that’s not the case.

Thanks again for replying. There were some good suggestions of things to look 
into and it was a help.

Cheers,
Eric Goodwin


On August 8, 2016 at 4:44:17 PM, José Valim (jose.va...@plataformatec.com.br) 
wrote:

There are a couple questions you should ask yourself:

1. Why are you trapping exists?

2. What happens when the worker dies?

3. What happens when the connection dies?

4. I believe hackney already ships with its own pools, can't you use them?

In any case, it seems your code does not link the worker process with the 
connection process. This means that, if the worker is suddenly killed, the 
connection will leak. However, given you are trapping exists, I believe it can 
only happen if the :kill message is used to kill the worker process (which is 
something supervisors may use).

If you really need your own pool, the simplest solution would be to remove the 
trapping of exits and link the two processes. This way you answer question by 
not trapping and you guarantee the worker will die when the connection dies and 
vice-versa.




José Valim
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D

On Mon, Aug 8, 2016 at 6:59 PM, Eric Goodwin <e...@ericgoodwin.com> wrote:
I am using poolboy to manage a pool of search workers. 
Each search worker is a genserver and has a hackney connection in it's state. 
For some reason, we're getting a leak where hackney is keeping connections 
open. The search processes only have the one connection in the state, but can 
have quite a few connections in it's process library. 

Here are main parts of the Search module.
https://gist.github.com/ericgoodwin/0d7dcd9d0f43c75337dc43a5df0423b2

Any ideas why we'd be getting a leak with connections staying open in the 
process library?
Thanks!





--
You received this message because you are subscribed to the Google Groups 
"elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-talk/7436695e-b28b-4ba2-9a9d-efaa47d3dde6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google 
Groups "elixir-lang-talk" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/elixir-lang-talk/lVhDSabpyjo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
elixir-lang-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-talk/CAGnRm4%2Bt665kpVxSA_YroZf83tKSNwuiEg4pp7uMxL%2BZxiB1tA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-talk/etPan.57aa4e2b.23ecbed9.e128%40goodwin.co.
For more options, visit https://groups.google.com/d/optout.

Reply via email to