rypa
Gracefully handling Tds connection errors
Hey all,
I’ve an Oban worker making a connection to a remote MSSQL DB to run a query and then process the results.
We’re using Tds to manage this and it works great when everything’s set up correctly.
Every now and again the underlying VPN isn’t established and despite the correct DB creds, the connection will fail resulting in a logged error:
[error] Tds.Protocol (#PID<0.864.0>) failed to connect: ** (Tds.Error) tcp connect: econnrefused
My frustration is that the initial connection function start_link/1 will almost always return {:ok, <pid>} so attempts to have a try rescue block aren’t matching – even without DB creds I get the ok tuple then a :killed error and shell reset (locally).
I’m hoping to to find a way to catch this error, handle the case and let the worker just retry. A Sentry issue is pointing to DBConnection for the source of the error, but I’m not certain how I can use that info.
Appreciate any insight ![]()
Most Liked
rypa
So, the logged messaging wasn’t interfering with the worker’s performance, just a ping from DBConnection internals.
As queries do fail when the connection is improper, but work even when logs are streaming (this is mostly a local IEx problem), I’ve opted instead of filter out the logging. ![]()
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
- #javascript
- #code-sync
- #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









