Closed stankudrow closed 2 months ago
@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.
@boolka , @gnomeby , @DaniilAnichin , @pufit , @KPull , @lxneng , could you possibly share your thoughts, leave your comments and review this PR as well?
OK. will see.
@gnomeby , @long2ice , could you have a thorough look at this work?
@boolka , could you review this PR with the approve of yours when an agreement with (maybe almost) all items on this work will be attained?
@gnomeby , the same request for a review, s'il vous plaît.
Thanks!
Not working for me: ` 2024-08-26 12:16:04 asynch.proto.connection WARNING | Connection was closed, reconnecting.
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.