-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PG.connect
raising PG::ConnectionBad
leaves behind open socket/file descriptor
#439
Comments
Previously it was kept open until the PG::Connection was garbage collected. Fixes ged#439
Thank you @bensheldon for filing this issue and providing this very useful repro script! I first assumed that this resource leak is due to changes from pg-1.2 to 1.3, but your script shows the same behavior in pg-1.0.0. I made a proposal in #440 to fix this issue. Could you @adibsaad please give it a try? |
@larskanis thank you 🙌 I tried it locally and it looks good. The IO objects are being closed, and I no longer see an accumulation of open file descriptors 👍 🎉 And I'm a bit surprised that this hasn't been noticed before, so yay to progress! |
When unable to connect to a non-running database server
PG.connect
initializes aPG::Connection
but does not clean it up. This leaves behind an open socket and file descriptor that are not closed until the Ruby garbage collector runs.(I'm the maintainer of GoodJob, and a user reported running out of fds because of a bad connection: bensheldon/good_job#530)
I put together a quick script to reproduce the behavior:
Resulting in...
The text was updated successfully, but these errors were encountered: