Feature request: POOLED dataSource connection lifetime

7 views
Skip to first unread message

Monte Ohrt

unread,
Nov 20, 2019, 11:34:38 AM11/20/19
to mybatis-user
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!

Guy Rouillier

unread,
Nov 20, 2019, 11:50:06 PM11/20/19
to mybati...@googlegroups.com
> --
> 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 mybatis-user...@googlegroups.com.
> 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

Reply all
Reply to author
Forward
0 new messages