DBConnection.ConnectionError on deploy

I have a small server on render.com, but recently switched the database to be on AWS. Now every time I deploy, appsignal is giving me these warnings: DBConnection.ConnectionError. The database isn’t very busy, and I am not too sure how to fix this. Any ideas?

Do you have more details of the error? (Does it also mention something about ‘client exited’?)

It could be an issue of (missing) connection draining. That is, it’s still serving request while it’s not fully up and running (anymore). This is a guess but one I’ve seen in my own deployment. (requests could be triggered by healthcheck/load balancer)

If it is the above or you would like to test it out if it maybe fixes things for you, cowboy connection draining can be implemented with (for example) the following plug https://hexdocs.pm/plug_cowboy/Plug.Cowboy.Drainer.html

1 Like

Thanks very much, it works :grinning:. Any clue why this is not set by default on phoenix?

Seems there was quite some discussion about it and also where the functionality should live (phoenix, plug, cowboy or ranch) Seems just days ago it’s added to Cowboy 2.8 see https://github.com/ninenines/cowboy/issues/915

Maybe, but this is just a wild guess, the origin of not having this draining built in lies in the hot upgrading ability of erlang code? And also exists/evolved before cloud/k8s architectures?

Anyway looks like it’s coming as a built in feature in the near future. :slight_smile: