LSylvester

LSylvester

Hey guys,

I’m currently using Poolboy to manage a pool of AMQP connections. In my unit tests, I have some that kill connections to test the service comes back. However, Poolboy dishes out dead connections because the kill in the actual connection module takes a while to bubble up to the GenServers terminate function. I’m following the advice given for AMQP, but it just isn’t working out.

Is there a decent solution to this?

Thanks,
Lee

Showing Posts 1 to 6

fishcakez

fishcakez

Ecto Core Team

I can’t quite understand your setup but you can prevent poolboy giving the worker to the next process by monitoring the worker and waiting for the :DOWN. GenServer.stop of the worker will provide this guarantee. This works because poolboy is link’ed to the worker processes, and exit signals are sent before monitor signals. Therefore poolboy is guaranteed to have the exit signal in it is message queue before process receives the :DOWN. This means poolboy will handle the exit signal first and replace the worker.

LSylvester

LSylvester OP

That’s what I’m doing now. So, I have a pool which has many workers. Each worker is a GenServer with a Connection in its state. If I kill the connection and put the worker back, then manage to check it out again soon after, the worker hasn’t yet had its :DOWN handler called, and so the next process to use it crashes.

LSylvester

LSylvester OP

What would be really nice is if Poolboy checked for a particular function in the worker, such as an is_ready() function, where the server could check if the Connection objects PID was alive and return true or false. That would solve the issue, I think.

fishcakez

fishcakez

Ecto Core Team

That isn’t quite the same as what I said. I said monitor the worker and wait for that go to :DOWN.

fishcakez

fishcakez

Ecto Core Team

Would poolboy be making a call to the worker? If the worker is busy this blocks the pool waiting on a single worker. This could be prevented by having the worker do the checkin instead of the calling process. However then the worker needs to do the monitoring instead of poolboy, and the worker needs to know about poolboy, and suddenly everything is different. I have a library that follows a similar pattern: GitHub - fishcakez/sbroker: Sojourn-time based active queue management library · GitHub but by making some hard problems easier it also makes some easy problems harder. I would not recommend it unless it can solve a problem that a simpler solution can not.

darnahsan

darnahsan

I might. be facing the same issue in my application, did you get to a solution for this @LSylvester

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews