Feature request: POOLED dataSource connection lifetime

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Feature request: POOLED dataSource connection lifetime

Monte Ohrt
I use mybatis to connect to an AWS RDS read endpoint with multiple instances behind it. I use a POOLED dataSource to minimize connection handshakes. Mybatis will hold a pooled DB connection open indefinitely, which (for us?) results in very unbalanced usage of the read pool. What would help is a way to automatically close a pooled connection, either by lifetime limit in seconds and/or connection count limit. Currently we are using the underlying db connector to kill connections but this throws warnings and can cause errors at the application. We are planning on writing a wrapper to mybatis, but it would be great if mybatis supported it natively. If there is a way already, or someone has a better solution I have not thought of, I'd like to hear that too!

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/7e6e494e-9571-4624-8a63-8df59ae413b1%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: POOLED dataSource connection lifetime

Guy Rouillier-2
On Wed, 2019-11-20 at 08:34 -0800, Monte Ohrt wrote:

> I use mybatis to connect to an AWS RDS read endpoint with multiple instances
> behind it. I use a POOLED dataSource to minimize connection handshakes.
> Mybatis will hold a pooled DB connection open indefinitely, which (for us?)
> results in very unbalanced usage of the read pool. What would help is a way
> to automatically close a pooled connection, either by lifetime limit in
> seconds and/or connection count limit. Currently we are using the underlying
> db connector to kill connections but this throws warnings and can cause
> errors at the application. We are planning on writing a wrapper to mybatis,
> but it would be great if mybatis supported it natively. If there is a way
> already, or someone has a better solution I have not thought of, I'd like to
> hear that too!
> --
> You received this message because you are subscribed to the Google Groups
> "mybatis-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mybatis-user/7e6e494e-9571-4624-8a63-8df59ae413b1%40googlegroups.com
> .

This behavior will be controlled by the pool manager you use, which in turn is usually determined by your runtime environment.  
If you are using the default MyBatis connection pool, check the available parameters at https://mybatis.org/mybatis-3/configuration.html
under Environments - POOLED. For example, poolMaximumActiveConnections will set an active connection count limit, while poolPingQuery
will test a connection before it is used.  If this is not sufficient, you can use a different pool manager that meets your needs, and
configure MyBatis to access that pool via JNDI.

--
Guy Rouillier

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/ce8c3183ddabf1b504199e66d6fe30e57ebc3033.camel%40gmail.com.