Return bad connection from pool

85 views
Skip to first unread message

Ashok Kumar

unread,
Jun 4, 2021, 6:10:59 PM6/4/21
to mybati...@googlegroups.com
Dear Mybatis user
I am facing wierd issue with mybatis connection pool. I have described the
issue below.

I use spark thrift server to connect to from mybatis. It works well till
spark thriftserver is running good. When Spark thriftserver is restarted, I
start getting "broken pipe" issue. Eventhough thriftserver is restarted
properly, i get this issue.
This issue goes away only by restarting application.

I did some debug at mybatis code and found that there is no way to tell
mybatis connection pooling to remove bad connection from idle connection
pool when there is exception other than "ping connection".

I can use "ping connection" with default "poolPingConnectionsNotUsedFor" as
"0". But issue with this is its sync call. So everytime i execute query ,
ping will happen to execute test query, which i feel is not good idea.

I didn't find any other way to remove bad connection from pool, May somebody
pls suggest how to go forward with this issue.



--
Sent from: http://mybatis-user.963551.n3.nabble.com/

Guy Rouillier

unread,
Jun 5, 2021, 4:14:01 AM6/5/21
to mybati...@googlegroups.com
You found the proper solution. The only way to find and dispose of
invalid connections is to test them upon use.

MyBatis User's Guide says this for poolPingConnectionsNotUsedFor: "This
can be set to match the typical timeout for a database connection, to
avoid unnecessary pings." So, check your database, and see how long
outstanding idle connections are valid. For example, if the database
keeps connections open for 15 minutes, then perhaps set
poolPingConnectionsNotUsedFor to 10 to provide a little margin of
safety. Then you won't suffer overhead on every query.

--
Guy Rouillier

On 6/2/2021 2:29:18 AM, "'Ashok Kumar' via mybatis-user"
>--
>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/1622615358139-0.post%40n3.nabble.com.

Reply all
Reply to author
Forward
0 new messages