[转帖]Weblogic常见故障:JDBC Connection Pools_Tomcat, WebLogic及J2EE讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  Tomcat, WebLogic及J2EE讨论区 »
总帖数
3
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 6708 | 回复: 2   主题: [转帖]Weblogic常见故障:JDBC Connection Pools        上一篇   下一篇 
panpan.nie
注册用户
等级:大校
经验:4754
发帖:217
精华:2
注册:1970-1-1
状态:离线
发送短消息息给panpan.nie 加好友    发送短消息息给panpan.nie 发消息
发表于: IP:您无权察看 2015-8-12 14:42:48 | [全部帖] [楼主帖] 楼主

WebLogic Server中数据库连接池是一个经常出问题的地方,总结一下出问题的原因和解决办法。

一、数据库连接泄漏
此类问题一般都是由于开发人员没有正确关闭数据库连接造成的。比如使用完Connection后,没有调用Connection.close()方法。

1、诊断方法
在Console中,找到Connection Pools Tab 和Diagnostics,设置以下属性(不同版本可能略有区别)
Enable Connection Leak Profiling 启用连接池泄漏的监控。
Enable Connection Profiling 启用连接池监控。
Inactive Connection Timeout 100 表示100秒后强制回收无效连接。默认0,表示使用完才释放回连接池。
无需重启,查看server的log,查找“A JDBC pool connection leak was detected”,如果有,看看是哪个类引起的。下面是一个数据库连接泄漏的例子:

A JDBC pool connection leak was detected.
A connection leak occurs when a connection obtained from the pool was not closed explicitly by
calling close() and then was disposed by the garbage collector and returned to the connection pool.
The following stack trace at create shows where the leaked connection was created.
Stack trace at connection create:
at weblogic.jdbc.wrapper.JTAConnection.init(JTAConnection.java:90)
at weblogic.jdbc.jta.DataSource.getConnection(DataSource.java:468)
at weblogic.jdbc.jta.DataSource.connect(DataSource.java:410)
at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:344)
at troubleshooting.servlets.JdbcConnections.service(JdbcConnections.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1077)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7047)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2773)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)


问题解决后,把三个属性设置回先前的值。
2、解决方法
正确的关闭数据库连接。具体代码如下:

Connection conn = null;
ResultSet rs = null;
preparedStatement pss = null;
try {
      conn = dataSource.getConnection(USERID,pASSWORD);
      pss = conn.prepareStatement("SELECT SAVESERIALZEDDATA FROM SESSION.pINGSESSION3DATA WHERE
      SESSIONKEY = ?");
      pss.setString(1,sessionKey);
      rs = pss.executeQuery();
      pss.close();
}
catch (Throwable t) {}
finally {
      try
      {
            if (conn != null) conn.close();
      }
catch (Exception e){}
}


二、数据库连接不够用

导致数据库连接不够用的原因主要有:
①某些程序占用connection时间过长,如果多个用户同时使用这些程序,则会导致连接不够用。
②线程死锁,无法释放connection。
1、诊断方法
①监控参数:Waiting For Connection High Count
[domain_name]-> Enviroment -> Servers -> [Server] -> Monitoring -> JDBC查看参数:Waiting For Connection High Count
如果没有此参数,手工添加进来,该参数表示在没有可用连接的情况下,应用程序等待连接的最大个数。调整后的连接池最大值 = 调整前的连接池最大值 + Waiting For Connection High Count。一般来说,数据库连接池的大小与最佳并发用户数相当。

②在Server Log中,明确抛出下列异常:

java.sql.SQLException: Internal error: Cannot obtain XAConnection
weblogic.common.resourcepool.ResourceLimitException: No resources currently available in pool
BankConnectionPool to allocate to applications, please increase the size of the pool and retry..
at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1493)
at weblogic.jdbc.jta.DataSource.getConnection(DataSource.java:455)
at weblogic.jdbc.jta.DataSource.connect(DataSource.java:410)
at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:344)
at troubleshooting.servlets.JdbcConnections.service(JdbcConnections.java:80)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1077)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7047)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2773)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)


如果此时观察connection的监控,会发现所有connection 都是Active,而且还有大量请求等待connection。
2、解决方法
①提高Maximum Capacity数量,该值一般略大于峰值情况下的数据库连接数。Services > JDBC > Connection Pools > BankConnectionPool > Configuration > Connections
②重点检查synchronize代码段和涉及数据库锁的代码。如果有必要,可以查看thread dump,看看线程在忙什么和等什么。

三、数据库连接使用超时
此类问题一般是由于某些数据库操作时间比较长,超过了Inactive connection timeout的设置。
1、诊断方法
在Server Log中,明确有下列提示,并且在提示后抛出应用异常:

Forcibly releasing inactive resource "weblogic.jdbc.common.internal.ConnectionEnv@132967d" back into the pool BankConnectionPool".这里无法列出应用异常,因为每个应用都不一样,不过很有可能会抛出空指针异常,因为Connection被强制放回池中了,继续使用一个空对象会抛出该异常。


2、解决方法
在高级参数中,提高Inactive connection timeout数量。

Services > JDBC > Connection Pools > BankConnectionPool > Configuration > Connections


四、事务超时
此类问题一般是由于某些数据库操作时间比较长,超过了JTA Timeout Seconds的设置。
1、诊断方法
在Server Log中,明确抛出异常:

weblogic.transaction.internal.TimedOutException: Transaction timed out after 300 seconds


2、解决方法
提高Services > JTA Configuration > Timeout Seconds数量。
注意这个参数应该小于Inactive connection timeout的值,因为事务必须在连接超时前完成。如果想分析究竟是哪些SQL语句导致事务超时,可以打开日志AdminServer > Logging > JDBC,选中Enable JDBC Logging,并设置JDBC Log File Name。




赞(0)    操作        顶端 
联动大白
注册用户
等级:列兵
经验:91
发帖:0
精华:0
注册:2015-5-27
状态:离线
发送短消息息给联动大白 加好友    发送短消息息给联动大白 发消息
发表于: IP:您无权察看 2019-7-11 0:30:00 | [全部帖] [楼主帖] 2  楼

为了方便大家阅读,我对文章中错误号来解释一下吧!

Error Id: BEA-001074

Title: A JDBC pool connection leak has been detected. A connection leak occurs when a connection obtained from the pool was not closed explicitly by calling close() and then was disposed by the garbage collector and returned to the data source connection pool. The following stack trace at create shows where the leaked connection was created. {0}

Action:

Close the connection appropriately.

Cause:

A JDBC pool connection leak was detected. A connection leak occurs when a connection obtained from the pool was not closed explicitly by calling close() and then was disposed by the garbage collector and returned to the data source connection pool. A stack trace is printed indicating where the leaked connection was created.


也许你已明白,但对一个人有用也是我存在的理由!^_^ By:持之以恒的大白

-- 来自: 北京联动北方科技有限公司



赞(0)    操作        顶端 
Bobo226
注册用户
等级:上尉
经验:548
发帖:0
精华:0
注册:2020-1-7
状态:离线
发送短消息息给Bobo226 加好友    发送短消息息给Bobo226 发消息
发表于: IP:您无权察看 2023-4-25 11:20:06 | [全部帖] [楼主帖] 3  楼

   次数、温度、引、禁忌以及服后的注意事项等,作比较详细的介绍。适用器皿煎时最好用陶器、砂锅、不锈钢器皿等,切忌用带油垢的锅、铁锅、铝锅和其它金属器皿。七乐彩app 因为油垢中可能含有致癌物——34苯并芘,会对人体健康造成危害

铁器可以和汤中的鞣质、油脂、生物碱、蒽醌类、英国乐透8开奖 香豆素及其甙等成分发生化学反应,服后对人体产生不良影响。准备工作煎前要先检查物是否有发潮霉变或虫蛀变质,然后用冷水将剂浸湿,过几分钟后加入适量的冷水煎熬。放入的冷水一定要清洁,没有杂质。头煎放入的冷168开奖app 水应超过剂面两寸左右,二煎、三煎水量酌减。





赞(0)    操作        顶端 
总帖数
3
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论