How to handle stale connections?

て烟熏妆下的殇ゞ 提交于 2019-12-02 18:39:25

We had the same issue at first login in the morning on one of our production systems. Solution was to set the minimum size for the connection pool to zero.

With minimum size set to a value greater than zero (e.g., one), timed out connections are removed from the pool when they are detected as not valid, but some of them (in the example above, the last one) remains in the pool (if the minimum size is one, one connection stays in the pool, even if it is not yet a valid connection).

Next time an application request a connection, the not valid one is served, resulting in the exception.

Setting minimum size to zero, all non valid connections are removed from the pool, so there is no chance the connection served to the application is not yet valid (because, if it is valid, it stays in the pool, if it is not, is removed from the pool).

Using the pretest could be a valid alternative, but will take an extra effort, because every time the connection is being served to the application, is tested.

i got the answer for this

using pretest old connection and new connection we can solve this issue.. the pretest query should be a basic query (select sysdate from ..)which runs anytime..

and time interval should be maximum hence the application server will not get overhead

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!