Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shutdown process #44

Closed
alexcastano opened this issue Jun 1, 2023 · 4 comments
Closed

Shutdown process #44

alexcastano opened this issue Jun 1, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@alexcastano
Copy link
Contributor

Hello!

It seems like the library doesn't handle the shutdown process. The pool dies but the workers are still alive, which is very inconvenient. I took a quick look at poolboy and it uses a supervisor where the workers are placed to handle the shutdown process correctly. Do you have a plan to do something similar?

Thank you!

@general-CbIC
Copy link
Owner

Hello!

Thank you for your issue!

This is a bug. Poolex also uses supervisor to run workers under it. But it seems the current implementation missed an important terminate callback. I will fix it.

It will help a lot if you tell me how to reproduce this situation :)

@general-CbIC general-CbIC added the bug Something isn't working label Jun 1, 2023
@alexcastano
Copy link
Contributor Author

Poolboy has a similar issue; it has an async shutdown. My mistake.

You can reproduce the issue very quickly. You can execute the following iex sequence:

iex(3)> {:ok, spid} = Poolex.start_link(pool_id: :agent_pool, worker_module: Agent, worker_
args: [fn -> 5 end], workers_count: 1)
{:ok, #PID<0.1336.0>}
iex(4)> Process.monitor(spid)
#Reference<0.4248042741.3728474113.42168>
iex(5)> Poolex.run!(:agent_pool, fn pid -> Process.monitor(IO.inspect(pid)) end)
#PID<0.1338.0>
#Reference<0.4248042741.3728474113.42180>
iex(6)> GenServer.stop(:agent_pool)
:ok
iex(7)> flush()
{:DOWN, #Reference<0.4248042741.3728474113.42168>, :process, #PID<0.1336.0>,
 :normal}
{:DOWN, #Reference<0.4248042741.3728474113.42180>, :process, #PID<0.1338.0>,
 :shutdown}
:ok

As you can see, the down message from poolex id is received before the worker one.

I hope it helps.

@general-CbIC
Copy link
Owner

Hello, @alexcastano!

The bug should have been fixed in version 0.7.1.

@alexcastano
Copy link
Contributor Author

Excellent work!! 👏🏻 👏🏻 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants