Skip to content

Conversation

@fatkodima
Copy link
Contributor

Currently, when a new connection is created and the connection pool reaches its maximum size, it just removes some old connection, but without closing. So it is possible to end up with lots of lingering opened connections, which will not be reused and waste process' opened fds.

This PR makes sure to close discarded connections.

@jjb
Copy link

jjb commented Dec 4, 2024

@tenderlove what do you think?

@tenderlove tenderlove merged commit a4d93fd into drbrain:master Dec 4, 2024
16 checks passed
@fatkodima fatkodima deleted the close-discarded-connections branch December 4, 2024 19:55
@pda
Copy link

pda commented Jul 1, 2025

Would these @ques[oldest].pop connections usually be implicitly closed via garbage collection, assuming nothing else is holding a reference to them? Or is there nothing in GC that would release the file descriptors etc?

Edit: I suspect not… I don't always believe LLMs but this sounds fairly legit:

GC may eventually free the object, but there's no guarantee when, and the file descriptor may remain open in the meantime.
Relying on GC for closing FDs is unsafe and will likely lead to file descriptor leaks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants