aspose file tools*
The moose likes JDBC and the fly likes MySql - XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MySql - XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected" Watch "MySql - XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected" New topic
Author

MySql - XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected

Arun Prasath
Ranch Hand

Joined: May 23, 2007
Posts: 80
Hi All,

Could you please tell me why I get the following exception in Mysql?. I try to run some batches from Sessin Bean.

om.mysql.jdbc.jdbc2.optional.MysqlXAException: XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected at com.mysql.jdbc.jdbc2.optional.MysqlXAConnection.mapXAExceptionFromSQLException(MysqlXAConnection.java:607)
at com.mysql.jdbc.jdbc2.optional.MysqlXAConnection.dispatchCommand(MysqlXAConnection.java:586)
at com.mysql.jdbc.jdbc2.optional.MysqlXAConnection.end(MysqlXAConnection.java:481)
at com.sun.gjc.spi.XAResourceImpl.end(XAResourceImpl.java:100)
at com.sun.jts.jta.TransactionState.rollback(TransactionState.java:199)
at com.sun.jts.jtsxa.OTSResourceImpl.rollback(OTSResourceImpl.java:311)
at com.sun.jts.CosTransactions.RegisteredResources.distributeRollback(RegisteredResources.java:1049)
at com.sun.jts.CosTransactions.TopCoordinator.rollback(TopCoordinator.java:2298)
at com.sun.jts.CosTransactions.CoordinatorTerm.rollback(CoordinatorTerm.java:542)
at com.sun.jts.CosTransactions.TerminatorImpl.rollback(TerminatorImpl.java:305)
at com.sun.jts.CosTransactions.CurrentImpl.rollback(CurrentImpl.java:766)
at com.sun.jts.jta.TransactionManagerImpl.rollback(TransactionManagerImpl.java:344)
at com.sun.enterprise.distributedtx.J2EETransactionManagerImpl.rollback(J2EETransactionManagerImpl.java:1129)
at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.rollback(J2EETransactionManagerOpt.java:426)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3855)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3673)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1410)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1347)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:205)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:83)
at $Proxy247.processAlert(Unknown Source)
at com.juliusbaer.adex.batch.beans.AlertGeneratorService.generateAlertBreaches(AlertGeneratorService.java:130)
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:585)
at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1011)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:175)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4093)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:483)
at com.sun.ejb.Invocation.proceed(Invocation.java:498)
at com.juliusbaer.adex.interceptor.LoggingIntercepter.writeLogging(LoggingIntercepter.java:37)
at sun.reflect.GeneratedMethodAccessor20808.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:579)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:483)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:205)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4066)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:197)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:83)
at $Proxy269.generateAlertBreaches(Unknown Source)
at com.juliusbaer.adex.batch.beans.MessageReceiverService.onMessage(MessageReceiverService.java:54)
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:585)
at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1011)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:175)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4093)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:483)
at com.sun.ejb.Invocation.proceed(Invocation.java:498)
at com.juliusbaer.adex.interceptor.LoggingIntercepter.writeLogging(LoggingIntercepter.java:37)
at sun.reflect.GeneratedMethodAccessor20808.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:579)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:483)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:205)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4066)
at com.sun.ejb.containers.MessageBeanContainer.deliverMessage(MessageBeanContainer.java:1111)
at com.sun.ejb.containers.MessageBeanListenerImpl.deliverMessage(MessageBeanListenerImpl.java:74)
at com.sun.enterprise.connectors.inflow.MessageEndpointInvocationHandler.invoke(MessageEndpointInvocationHandler.java:179)
at $Proxy274.onMessage(Unknown Source)
at com.sun.messaging.jms.ra.OnMessageRunner.run(OnMessageRunner.java:258)
at com.sun.enterprise.connectors.work.OneWork.doWork(OneWork.java:77)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Your transaction is being rolled back because a deadlock was detected. You need to examine what resources were deadlocked, then try to figure out why. Remember that in RDBMSs deadlocks should be infrequent but not entirely unexpected (databases are shared resources after all). It might be that retrying the transaction will fix this. If a deadlock happens repeatedly in the same place you need to look at your database interactions to see if you can reorder them to avoid the deadlock. But step one is find out what is deadlocked and why.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Arun Prasath
Ranch Hand

Joined: May 23, 2007
Posts: 80
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MySql - XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected