Today, there is an option to specify a maxIdleDuration in the Pool settings, which kills idle connections after the duration is reached.
I'm hitting the following scenario:
I'm using a proxy (istio-proxy in tcp mode) to connection to a set of MySql nodes. The client connects to a single DNS endpoint, and the proxy takes care of balancing connections across the MySql nodes.
If I deploy the Mysql nodes (one by one), without redeploying the client, the clients re-connect to the nodes that are restarted earlier. This leads to a connection and hence a traffic imbalance, where the nodes that get redeployed earlier get more traffic, and the later ones get minimal traffic.
The connections are barely idle, and without a maxConnectionLifetime setting, the only option is to redeploy the client in order to rebalance the connections.
It will be really helpful to add this as a PoolOption, so that active connections are also cycled, and so that the connections get rebalanced across the different servers.
Hikari CP has a similar option (maxLifetime). It basically retires "inactive" connections in the pool provided the connection has reached its max Lifetime.