开发者社区> 问答> 正文

在系统访问高峰期出现无法获取数据库连接的异常。

最近遇到一个棘手的问题,请教各位能否查明报出异常的原因:
1:正常情况下系统运行没有问题,但是系统访问高峰情况下会出现,日志如下,这段日志出现一段时间之后,应用就会假死,持续1分钟左右之后恢复。

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException
: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/datasources/PnrDS
The error may exist in com/huifu/muser/common/dal/dao/MerUsrMapMapper.xml
The error may involve com.huifu.muser.common.dal.dao.MerUsrMapMapper.queryMerUsrMap
The error occurred while executing a query
Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: javax.resource.ResourceE
xception: IJ000453: Unable to get managed connection for java:jboss/datasources/PnrDS
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365)
at com.sun.proxy.$Proxy157.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:195)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:124)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:90)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40)
at com.sun.proxy.$Proxy158.queryMerUsrMap(Unknown Source)
at com.huifu.muser.service.core.cash.impl.CashReqServiceImpl.checkMerUsrMap(CashReqServiceImpl.java:267)
at com.huifu.muser.biz.cash.impl.CashReqManager2Impl.cashConfirmReq(CashReqManager2Impl.java:211)
at com.huifu.muser.webapp.controller.cash.CashController.cashConfirm2(CashController.java:200)
at sun.reflect.GeneratedMethodAccessor2127.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

2:我的应用框架是 spring3.0.5+mybatis3.1.1+JBoss7.1+oracle11+jdk1.6
3:负载均衡 netscaler,两台虚拟机,四核,内存8G,jvm启动参数配置如下:

-XX:+UseCompressedOops -XX:+TieredCompilation -Xms4096m -Xmx4096m -Xmn1024m -XX:PermSize=256M -XX:MaxPermSize=512M -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -XX:SurvivorRatio=8 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=0 -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 -Xnoclassgc -XX:+CMSClassUnloadingEnabled

4:我的数据库链接池是配置在jboss的配置文件standalone-ha.xml中,连接池配置为18-300,高峰期能达到300,即应用确实与数据库建立300链接,但是活跃链接在15左右,配置如下

screenshot

展开
收起
小旋风柴进 2016-03-04 17:08:48 4046 0
1 条回答
写回答
取消 提交回答
  • 可能是高峰来的太突然,瞬间大量请求要求创建新连接。创建新连接这个过程本身要消耗比较多资源,以至于应用无法响应其他请求

    2019-07-17 18:52:35
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
DTCC 2022大会集锦《云原生一站式数据库技术与实践》 立即下载
阿里云瑶池数据库精要2022版 立即下载
2022 DTCC-阿里云一站式数据库上云最佳实践 立即下载