gpt4 book ai didi

exception - 事务被回滚,当执行大量查询时(JBoss 5.1)

转载 作者:行者123 更新时间:2023-12-02 05:52:20 25 4
gpt4 key购买 nike

我在执行大量查询时遇到问题。

我需要在单个事务中执行超过 10, 000 个 native sql 查询。这些查询是动态生成的,并缓存在系统中。查询生成完成后,这些查询将在单个事务中一个接一个地发送和执行。该应用程序使用 EJB 3 开发并在 JBoss 5.1 上运行。

如果查询数量少于 7200(近似值),应用程序可以正常工作。但是如果有比这更多的查询,该方法将抛出 EJB 异常并且事务被回滚。没有数据被持久化。

这是回滚发生的地方。 [仅当查询数量超过 7200 时]

 @TransactionAttribute(TransactionAttributeType.REQUIRED)
public void confirmOrder(String[] queries) {
for (int i = 0; i < queries.length; i++) {
em.createNativeQuery(queries[i]).executeUpdate(); //line # 108
}
BigInteger bigInt = (BigInteger)em.createNativeQuery("select max(id) from order_item").getSingleResult();
return bigInt!=null ? Long.valueOf(bigInt.longValue()) : null;
}

有没有办法增加可以在事务中执行的查询数量?请对此提出您的建议。

/维拉杰

The following is the error trace.

17:36:33,233 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TransactionReaper_18] - TransactionReaper::check timeout for TX -3f57767b:bc55:4fd9d129:e3a3 in state RUN
17:36:33,238 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TransactionReaper_7] - TransactionReaper::doCancellations worker Thread[Thread-10,5,jboss] successfully canceled TX -3f57767b:bc55:4fd9d129:e3a3
17:36:33,635 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TransactionReaper_18] - TransactionReaper::check timeout for TX -3f57767b:bc55:4fd9d129:e3bf in state RUN
17:36:33,636 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicAction_58] - Abort of action id -3f57767b:bc55:4fd9d129:e3bf invoked while multiple threads active within it.
17:36:33,636 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.CheckedAction_2] - CheckedAction::check - atomic action -3f57767b:bc55:4fd9d129:e3bf aborting with 1 threads active!
17:36:34,135 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TransactionReaper_18] - TransactionReaper::check timeout for TX -3f57767b:bc55:4fd9d129:e3bf in state CANCEL
17:36:34,635 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TransactionReaper_18] - TransactionReaper::check timeout for TX -3f57767b:bc55:4fd9d129:e3bf in state CANCEL_INTERRUPTED
17:36:34,636 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TransactionReaper_6] - TransactionReaper::check worker Thread[Thread-10,5,jboss] not responding to interrupt when cancelling TX -3f57767b:bc55:4fd9d129:e3bf -- worker marked as zombie and TX scheduled for mark-as-rollback
17:36:34,636 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TransactionReaper_11] - TransactionReaper::check failed to mark TX -3f57767b:bc55:4fd9d129:e3bf as rollback only
17:36:34,904 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_4] TwoPhaseCoordinator.afterCompletion - returned failure for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@5a720719
17:36:34,926 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TransactionReaper_13] - TransactionReaper::doCancellations worker Thread[Thread-10,5,jboss] missed interrupt when cancelling TX -3f57767b:bc55:4fd9d129:e3bf -- exiting as zombie (zombie count decremented to 0) ........
......

17:36:34,935 ERROR [CardOrderCreateFacadeBean] Confirming order is failed.
javax.ejb.EJBTransactionRolledbackException: Executing an update/delete query
at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:115)
at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:194)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.security.RunAsSecurityInterceptorv2.invoke(RunAsSecurityInterceptorv2.java:94)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.security.RoleBasedAuthorizationInterceptorv2.invoke(RoleBasedAuthorizationInterceptorv2.java:201)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:186)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
........................
...............

Caused by: javax.persistence.TransactionRequiredException: Executing an update/delete query
at org.hibernate.ejb.QueryImpl.executeUpdate(QueryImpl.java:48)
at rk.ejb.eao.OrderEAOImpl.confirmOrder(OrderEAOImpl.java:108)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
at org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:69)
at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:76)
at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:62)
at sun.reflect.GeneratedMethodAccessor358.invoke(Unknown Source)
........
.......

最佳答案

您可以根据需要在全局或方法级别增加事务超时。

  • 如果你想在方法级别做,下面的注解可以用过的。 (超时设置为 1500 秒)@TransactionTimeout(1500)
  • 如果您想在全局范围内执行此操作,则必须编辑位于 [server-instance]/deploy 目录中的 transaction-jboss-beans.xml 并更改超时参数值。例如:超时值为 1200 秒

    < property name="transactionTimeout"> 1200 < /property >

更多信息:https://community.jboss.org/wiki/TransactionTimeout

关于exception - 事务被回滚,当执行大量查询时(JBoss 5.1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11043306/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com