-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Current Behavior:
As of now, when the connection pool reaches its maximum number of connections (connections_max), any additional requests for connections result in a TooManyConnections exception. This behavior can be problematic in high-load scenarios where it's preferable to queue the connection requests rather than immediately reject them.
Proposed Feature:
I propose the implementation of a waiting mechanism within the connection pool. Instead of outright rejecting new connection requests when the pool is at maximum capacity, the pool would have the ability to put these requests into a waiting state. The waiting requests would then be fulfilled as soon as a connection is returned to the pool.
Implementation Suggestion:
This feature could potentially be implemented using threading condition variables. By integrating a condition variable, the pool can put threads into a wait state when the pool is full. Once a connection is released back into the pool, one of the waiting threads can be notified to proceed with its connection request.
Benefits:
- Better handling of high-load scenarios.
- Increased flexibility in managing database connections.
- Enhanced control over connection pooling behavior, particularly in server environments where rejecting a connection might not be the best approach.
I believe this enhancement would be beneficial to many users of the clickhouse-pool package, particularly those dealing with dynamic, high-traffic applications.