使用Oracle UCP时连接已关闭 [英] The connection is closed when using Oracle UCP

查看:138
本文介绍了使用Oracle UCP时连接已关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Oracle UCP v 12.1.0.2.0时出现随机错误连接已关闭:连接已关闭"错误.看起来连接已标记为已关闭 oracle.ucp.jdbc.proxy.JDBCConnectionProxyFactory#invoke:

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);
}

Clock.isBefore(this.creationTS,this.m_jdbcPooledConnection.getAvailableStartTime())返回true.

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

有人可以解释一下这张支票是做什么用的吗?

Could somebody please explain what this check is for?

getAvailableStartTime是在将连接重新连接到池时设置的,creationTS是在创建JDBCConnectionProxyFactory时设置的,而在断开连接时将创建它的设置.

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.

isBefore看起来像这样:

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:尝试过的验证查询从双重选择1"-无效

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

推荐答案

如果Clock.isBefore(this.creationTS, this.m_jdbcPooledConnection.getAvailableStartTime())返回true,则表明UCP已重新收集连接并使其重新可用.如果您在UCP中打开连接收集,通常会发生这种情况. UCP会检测何时借用了连接但使用时间过长(应用程序设计欠佳),并且为避免连接泄漏,它将抢回连接并使其在池中可用.如果原始线程随后醒来并尝试使用该连接,则会出现connection is closed错误.

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.

这篇关于使用Oracle UCP时连接已关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆