Stuck Threads使用Spring,EclipseLink JPA进入应用程序并部署在weblogic中。
这些卡住的线程仅在应用程序的负载测试期间和耐久性测试期间出现。在一小时或两小时的负载测试中,一切都很好,应用程序中没有卡住的线程。
这里我附加了两个卡住线程的日志,
Thread1:
####<Apr 16, 2014 1:19:34 AM IST> <Error> <WebLogicServer> <esxsrv12s1> <AdminServer> <[ACTIVE] ExecuteThread: '23' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1397591374727> <BEA-000337> <[STUCK] ExecuteThread: '32' for queue: 'weblogic.kernel.Default (self-tuning)' has been busy for "644" seconds working on the request "Workmanager: default, Version: 0, Scheduled=true, Started=true, Started time: 644406 ms
", which is more than the configured time (StuckThreadMaxTime) of "600" seconds. Stack trace:
java.lang.Throwable.getStackTraceElement(Native Method)
java.lang.System$2.getStackTraceElement(System.java:1153)
java.util.logging.LogRecord.inferCaller(LogRecord.java:490)
java.util.logging.LogRecord.getSourceClassName(LogRecord.java:259)
org.eclipse.persistence.logging.LogFormatter.format(LogFormatter.java:64)
com.myapp.common.logging.CustomAbstractSessionLog.computeMessage(CustomAbstractSessionLog.java:74)
com.myapp.common.logging.CustomAbstractSessionLog.internalLog(CustomAbstractSessionLog.java:56)
com.myapp.common.logging.CustomAbstractSessionLog.log(CustomAbstractSessionLog.java:30)
org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:3100)
org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:4218)
org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:4190)
org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:4166)
org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:4063)
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1148)
org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:84)
org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:456)
org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:732)
org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:701)
org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:321)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
$Proxy103.getLetters(Unknown Source)
sun.reflect.GeneratedMethodAccessor998.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
Thread2:
####<Apr 16, 2014 1:49:06 AM IST> <Error> <WebLogicServer> <esxsrv12s1> <AdminServer> <[STANDBY] ExecuteThread: '90' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1397593146086> <BEA-000337> <[STUCK] ExecuteThread: '41' for queue: 'weblogic.kernel.Default (self-tuning)' has been busy for "637" seconds working on the request "Workmanager: default, Version: 1, Scheduled=true, Started=true, Started time: 637469 ms
", which is more than the configured time (StuckThreadMaxTime) of "600" seconds. Stack trace:
org.eclipse.persistence.logging.LogFormatter.format(LogFormatter.java:45)
com.myapp.common.logging.CustomAbstractSessionLog.computeMessage(CustomAbstractSessionLog.java:74)
com.myapp.common.logging.CustomAbstractSessionLog.internalLog(CustomAbstractSessionLog.java:56)
com.myapp..common.logging.CustomAbstractSessionLog.log(CustomAbstractSessionLog.java:30)
org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:3100)
org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:4218)
org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:4190)
org.eclipse.persistence.sessions.server.ExternalConnectionPool.releaseConnection(ExternalConnectionPool.java:97)
org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:581)
org.eclipse.persistence.sessions.server.ClientSession.executeCall(ClientSession.java:207)
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:207)
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193)
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:264)
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:646)
org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2611)
org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2570)
org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:420)
org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1081)
org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:844)
org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1040)
org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:392)
org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1128)
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2871)
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1516)
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1498)
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1463)
org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:485)
org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:742)
我们检查了数据库,但DB中没有锁。没有长时间运行的查询。最大DB CPU和内存使用率也不超过40%。
这里有什么问题,请帮我解决这个问题。
答案 0 :(得分:0)
我们遇到了很多线程问题。您可能会发现此链接很有用:
http://wiki.eclipse.org/EclipseLink/FAQ/JPA#How_to_diagnose_and_resolve_hangs_and_deadlocks.3F
我们发现卡住的线程与数据库死锁无关。本质上,EclipseLink缓存在缓存访问上是死锁,因为一个线程无法释放锁定而另一个线程会要求锁定对象。
卡住的线程最大时间(在您的示例中为600秒)通常是J2EE容器中的可配置参数。根据我们的经验,增加或减少这个数字是没有好处的,因为一旦线被卡住它就被卡住直到被容器杀死。
最终为我们解决的问题是使我们所有的@ManyToOne关系FetchType.LAZY。这会带来性能损失,因为所有这些查询都需要额外的SQL查询,但这是我们发现解决问题的唯一方法。您应该尝试该链接中的其他建议,看看它们是否适合您。
此处提供更多信息:
https://www.eclipse.org/forums/index.php/m/1108983/#msg_1108983