-
Notifications
You must be signed in to change notification settings - Fork 44
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
Fix Pool
dangling connections
#109
Conversation
…ng pool.acquire() invocations
@long2ice , I need thorough reviews on this PR, it is about changes in architecture, could you ping/tag other maintainers? @DFilyushin, please review this PR as well (also keeping on the discussion #108 ). |
@DFilyushin , many thanks for approval. |
OK. will see. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not that big in terms of maintaining, usually I just request to fix bugs or something like that.
I've looked through this one, found no issues except a minor comment on debug logs
…valuation and optimisation details
Thanks! |
Not working for me: 2024-08-26 12:16:35 asynch.pool WARNING | Connection lost |
The MRs #106 and #107 were only foresteps to the real problem: poor connection management via the
Pool
class. My colleagues found that the version 0.2.4 leaves unclosed/dangling connections to the ClickHouse. Rolling back to the previous v0.2.3 made this problem disappear. Moreover, there is the discussion #108 highlighting the same problem.This PR #109 addresses the dangling connection issue by injecting into the
Pool
class the interface for asynchronous context manager support. When entering a pool context, theminsize
connections are established. Within the pool context one can acquire up to themaxsize
connections, but not more orPoolError
will be raised. Before leaving the pool context, all connections get closed.Many thanks to the psycopg_pool open-source implementation and this article on psycopg3 pool design.
UPD
Sorry for overloading the PR with changes on
Connection
class, including tests onasynch.proto.Connection
class and some minor grooming or refactoring. That is the result of API alignment in my opinion + bringing more order and unification in the API.