ged / ruby-pg

A PostgreSQL client library for Ruby
Other
796 stars 180 forks source link

connection.reset don't check again DNS #558

Closed gagalago closed 8 months ago

gagalago commented 8 months ago

when using AWS aurora, the database can stay on the same host when the IP behind has changed, in that case it can be interesting that the reset of the connection check again if we have to connect to the same IP as during the new or to a new IP for the same host as provided initially.

We can see this article that explain it in more details https://blog.50projects.com/2023/04/fixing-rails-stickiness.html and how it affect a rails application on top of AWS aurora

larskanis commented 8 months ago

The blog post is almost one year old, until this issue is raised here in the issue tracker. :smile: Nevertheless I propose a fix in #559 . Would you mind to test it out?

bnferguson commented 8 months ago

Oh how timely is this?! I've been seeing a similar and related issue with a few setups (eg Nutanix, Aurora, EDB) where a failover where the server doesn't go away (just disconnects clients) or goes and comes back causes issues due to reconnecting to the old IP. This has caused a few outages as all other services (mostly Golang) seem to pick up on the change, while Ruby based ones stuck on the old IP.

I had a patch that's basically a simplified version of what that blog post lays out but while seeing about some upstream fixes found this issue and the PR! 🎉

@larskanis I tested your PR with my test setup I'd been using to dig into this problem and it fixes the issue completely. I'll comment over on the PR with more test details!

larskanis commented 8 months ago

pg-1.5.6 is released, fixing this issue. :tada:

bnferguson commented 8 months ago

Oh wow! That was so fast! Even got in before my release deadline today! 😂

Thank you so much!

larskanis commented 8 months ago

Doesn't happen that often, but in this case I was just waiting for a confirmation in order to make a release.

gagalago commented 7 months ago

thank you all

and sorry for the late reply