The connection is closed when using Oracle UCP

你离开我真会死。 提交于 2019-12-06 04:32:17

问题


I'm getting random " The connection is closed: The connection is closed" errors when using Oracle UCP, v 12.1.0.2.0. It looks like connection is marked as closed in oracle.ucp.jdbc.proxy.JDBCConnectionProxyFactory#invoke :

if(Clock.isBefore(this.creationTS, this.m_jdbcPooledConnection.getAvailableStartTime()) || Clock.isBefore(this.creationTS, this.m_jdbcPooledConnection.getBorrowedStartTime())) {
      this.m_closed = Boolean.valueOf(true);
}

The Clock.isBefore(this.creationTS, this.m_jdbcPooledConnection.getAvailableStartTime()) returns true.

Could somebody please explain what this check is for?

The getAvailableStartTime is set when connection is retured to the pool, the creationTS - is set when JDBCConnectionProxyFactory is being created and it's being created when giving connection away.

The isBefore looks like this:

public static boolean isBefore(long time1, long time2) {
        return time1 < time2 - 1000L;
}

So, is the condition for the cases when connection was returned less than a second ago?

ps: tried validation query "select 1 from dual" - no effect


回答1:


If Clock.isBefore(this.creationTS, this.m_jdbcPooledConnection.getAvailableStartTime()) returns true then it means that UCP has recollected the connection and made it available again. This typically happens if you turn on connection harvesting in UCP. UCP detects when a connection is borrowed but not used for too long (poorly designed application) and to avoid connection leaks it will grab the connection back and make it available in the pool. If the original thread then wakes up and attempts to use the connection it gets a connection is closed error.



来源:https://stackoverflow.com/questions/34557528/the-connection-is-closed-when-using-oracle-ucp

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