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

If the caller dies, the worker is returned to the pool, even if it's still busy #56

Closed
rlipscombe opened this issue Sep 12, 2014 · 4 comments

Comments

@rlipscombe
Copy link

I might be reading the source code wrongly, but it appears to me that if I do something like this:

x() ->
  W = poolboy:checkout(P, true),
  gen_server:call(W, Req),
  poolboy:checkin(P, W).

If x dies while inside gen_server:call (can it actually do that?), then W is returned to the pool, but it's still busy. That means that when someone checks it out later, their gen_server:call will be queued behind this one.

Is there any way to get around this?

@devinus
Copy link
Owner

devinus commented Sep 12, 2014

Do you want the worker to continue it's work even when the caller has died?

@rlipscombe
Copy link
Author

Well, that's a good question. Sometimes yes, sometimes no. In our particular case, usually no. Either the write is not that important, or it's a read, in which case it's wasted.

@rlipscombe
Copy link
Author

I had two thoughts:

  1. Get the worker to check itself back in. Requires adding some stuff to handle_call, which is awkward.
  2. link the two processes. If the caller dies, the worker dies. Poolboy will create a replacement worker, no?

@devinus
Copy link
Owner

devinus commented Sep 12, 2014

@rlipscombe You have many options, I don't find no. 1 awkward at all.

You can kill the worker as soon as it captures the caller EXITs. Many options are available to you, they all depend on your use case.

@devinus devinus closed this as completed Oct 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants