Weblogic的Transaction Timeout风波

Weblogic 10.3Transaction Timeout风波

 

近期系统在运行的过程中,执行一个复杂的业务逻辑运算时,该算法中SQL SELECT 执行得比较频繁,执行的逻辑花费时间比较长,结果就报Transaction Timeout错误了,具体错误信息为;

 

javax.ejb.EJBTransactionRolledbackException: EJB Exception: : Local Exception Stack:

Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DatabaseException

Internal Exception: java.sql.SQLException: The transaction is no longer active - status: 'Marked rollback. [Reason=weblogic.transaction.internal.TimedOutException: Transaction timed out after 32 seconds

BEA1-598C9FB93523589ECDD5]'. No further JDBC access is allowed within this transaction.

Error Code: 0

Call: SELECT COUNT(*) FROM UMGR_ROLE_MENU WHERE ROLE_ID='NONSTANDARD' AND MENU_ID='SD_RODER_QRY'

Query: DataReadQuery(sql="SELECT COUNT(*) FROM UMGR_ROLE_MENU WHERE ROLE_ID='NONSTANDARD' AND MENU_ID='SD_RODER_QRY'")

       at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333)

       at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.processExceptionForCommError(DatabaseAccessor.java:1419)

       at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:675)

       at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:526)

       at org.eclipse.persistence.internal.sessions.AbstractSession.executeCall(AbstractSession.java:980)

       at org.eclipse.persistence.internal.sessions.IsolatedClientSession.executeCall(IsolatedClientSession.java:131)

       at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:206)

       at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:192)

       at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:263)

    at org.eclipse.persistence.internal.queries.Datas

碰到上述问题解决办法为两个:

(1)Weblogic的配置,对于超时的会话加上:

@weblogic.javaee.TransactionTimeoutSeconds(value = 100)的标注

2)程序优化,减少数据查询执行的次数,通过优化,从30多秒到6秒。

 

经验总结:在效率的方面,90%的原因是处在程序上,应从程序的算法进行优化。

你可能感兴趣的:(eclipse,优化,exception,weblogic,ejb,menu)