上午发现系统发现缓慢(数据库连接池不足),配置组定位可能是某某功能的问题,但因为上午有人在使用4个计划上报数据,我怀疑是4个计划的问题。中午测试了下,每次新增数据,后台就会报数据库连接错误。
<2013-11-26 下午12时42分30秒 CST> <Warning> <Common> <BEA-000620> <Forcibly releasing inactive resource "autoCommit=false,enabled=true,isXA=
false,isJTS=true,vendorID=100,connUsed=true,doInit=false,'null',destroyed=false,poolname=JDBC Data Source-0,appname=null,moduleName=null,con
nectTime=107,dirtyIsolationLevel=false,initialIsolationLevel=2,infected=false,lastSuccessfulConnectionUse=1385440930984,secondsToTrustAnIdle
PoolConnection=10,currentUser=java.lang.Exception
at weblogic.jdbc.common.internal.ConnectionEnv.setup(ConnectionEnv.java:293)
at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:306)
at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:468)
at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:357)
at weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:83)
at weblogic.jdbc.jts.Driver.newConnection(Driver.java:907)
at weblogic.jdbc.jts.Driver.createLocalConnection(Driver.java:340)
at weblogic.jdbc.jts.Driver.connect(Driver.java:181)
at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:359)
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at com.comtop.struts.action.StatusExposingFilter.doFilter(StatusExposingFilter.java:131)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3242)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2010)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1916)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1366)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
,currentThread=Thread[[ACTIVE] ExecuteThread: '9' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads],lastUser=null,current
Error=null,currentErrorTimestamp=null," back into the pool "JDBC Data Source-0".>
Warning: Range A42-A45 contains more than one data cell. Setting the other cells to blank.
Warning: Range A38-A41 contains more than one data cell. Setting the other cells to blank.
看到这个错误本来想找下错误,但转念一想,还是全面了解下情况。又去问了下开发的同事,反馈说,是jxl的根据流创建excel的一行代码造成CPU飙高。
WorkbookSettings wbs=new WorkbookSettings();
wbs.setGCDisabled(true);--加上这段代码即可
Workbook wb = Workbook.getWorkbook(excelFile,wbs);
wbs.setGCDisabled(true);--加上这段代码即可
Workbook wb = Workbook.getWorkbook(excelFile,wbs);
测试时间从13s见到0.2s。
核心代码中过度使用System.gc()方法,增加CPU负荷。
在jxl.write.biff.File类对象方法colse和WorkbookParser类对象方法close中,对系统JVM垃圾回收进行了强制垃圾回收,在J2EE应用服务器中,我们是极力反对这种应用调度GC的做法,此种操作会极度影响系统性能和稳定性。