amnu3387
Ecto/Postgrex/DBConnection - How to be notified of failure
Ecto with the Postgrex adapter allow us to run a callback right after connect, with which we can call a function where the first argument will be:
%DBConnection{
conn_mod: Postgrex.Protocol,
conn_ref: #Reference<0.384196318.1471152129.192608>,
pool_mod: DBConnection.Task,
pool_ref: {#PID<0.734.0>, #Reference<0.384196318.1471152129.192606>}
}
The PID in pool_ref refers to the checked out connection in the pool. This is only called after a successful connection which is fine. Now when the back-end postgrex adapter runs into a problem (say I just plug off the database), I keep getting flooded with [error] Postgrex.Protocol (#PID<0.737.0>) disconnected: ** (Postgrex.Error) FATAL 57P01 (admin_shutdown): terminating connection due to administrator command, in which the PID refers to the checked out connections in the pool.
But because both the Repo.Pool and Repo.Supervisor trap exits I can’t seem to find a way of being notified of these failures, since the pool connections never actually exit. The recovery on the side of Ecto/PGex works just fine, but I would like to be able to do some stuff if all of a sudden all the pool connections are error’ing out. Is there any way of getting those errors to bubble up somehow or any other way you handle this?
Thanks
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









