0 Replies Latest reply on Mar 20, 2008 8:39 AM by Mario Kofler

    concurrent write, StaleObjectStateException, optimistic lock

    Mario Kofler Newbie

      hello,

      i hope someone can help me with my issue. it has to do with performance too but i thought i best post it in this subforum.

      i am using jboss 4.2 and ejb 3.0 with hibernate as entity manager

      so my test case would be to concurrently remove persistent entities from the database. i want to see how jboss performs for this situation. so i start with 5 concurrent users making some kind of select on the database and trying to remove 1 line per remove operation. clearly it can come to the following situation (for one single entity):

      user A user B
      read
      read
      remove
      remove

      in this case the user A will not be able to delete the entity anymore because it has been removed before. some code snippet:

      //em.refresh(director);
      em.remove(director);
      //em.flush();

      i already tried with the commented out lines, but this had no effect on the error that i get

      before i post the error log i want to remark that i already tried to set "optimistic locking" in hibernate via an @version attribute in my persistent entity. did not change nothing. i also did not find an answer in the net how to set "optimistic locking" for jboss at all. i found some "notes" on it in the official documentation (about what optimistic locking is) but no real "howto" activate it, and which deployment-descriptors to change.

      the same as the optimistic locking i already tried to set the "isolation level" of the jdbc driver and database to "SERIALIZABLE" also without effecting the error or performance :-( i am running out of ideas.

      i hope that someone has the time and can help me out with this issue, THANK YOU already in advance.

      so i get the following error:

      [exec] 08:05:05,660 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
      [exec] org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [vt.bean.entity.Director#699751]
      [exec] at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1765)
      [exec] at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2523)
      [exec] at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2697)
      [exec] at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:74)
      [exec] at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
      [exec] at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
      [exec] at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:146)
      [exec] at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
      [exec] at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
      [exec] at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
      [exec] at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
      [exec] at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515)
      [exec] at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)
      [exec] at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247)
      [exec] at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)
      [exec] at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
      [exec] at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1382)
      [exec] at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
      [exec] at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
      [exec] at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
      [exec] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
      [exec] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
      [exec] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      [exec] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
      [exec] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      [exec] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
      [exec] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      [exec] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
      [exec] at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
      [exec] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      [exec] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
      [exec] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      [exec] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
      [exec] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      [exec] at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
      [exec] at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:79)
      [exec] at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:70)
      [exec] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      [exec] at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:103)
      [exec] at $Proxy149.removeDirectors(Unknown Source)
      [exec] at org.apache.jsp.removeTool_jsp._jspService(removeTool_jsp.java:163)
      [exec] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      [exec] at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      [exec] at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:387)
      [exec] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
      [exec] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
      [exec] at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      [exec] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      [exec] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      [exec] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      [exec] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      [exec] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      [exec] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      [exec] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      [exec] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
      [exec] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      [exec] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      [exec] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
      [exec] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      [exec] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      [exec] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
      [exec] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      [exec] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
      [exec] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      [exec] at java.lang.Thread.run(Thread.java:619)
      [exec] 08:05:06,288 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@c7519c
      [exec] javax.persistence.EntityNotFoundException: Unable to find vt.bean.entity.Director with id 699751
      [exec] at org.hibernate.ejb.Ejb3Configuration$Ejb3EntityNotFoundDelegate.handleEntityNotFound(Ejb3Configuration.java:107)
      [exec] at org.hibernate.impl.SessionImpl.load(SessionImpl.java:797)
      [exec] at org.hibernate.ejb.AbstractEntityManagerImpl.wrapStaleStateException(AbstractEntityManagerImpl.java:639)
      [exec] at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:599)
      [exec] at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:524)
      [exec] at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)
      [exec] at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247)
      [exec] at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)
      [exec] at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
      [exec] at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1382)
      [exec] at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
      [exec] at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
      [exec] at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
      [exec] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
      [exec] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
      [exec] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      [exec] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
      [exec] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      [exec] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
      [exec] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      [exec] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
      [exec] at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
      [exec] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      [exec] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
      [exec] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      [exec] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
      [exec] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      [exec] at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
      [exec] at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:79)
      [exec] at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:70)
      [exec] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      [exec] at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:103)
      [exec] at $Proxy149.removeDirectors(Unknown Source)
      [exec] at org.apache.jsp.removeTool_jsp._jspService(removeTool_jsp.java:163)
      [exec] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      [exec] at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      [exec] at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:387)
      [exec] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
      [exec] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
      [exec] at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      [exec] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      [exec] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      [exec] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      [exec] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      [exec] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      [exec] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      [exec] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      [exec] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
      [exec] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      [exec] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      [exec] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
      [exec] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      [exec] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      [exec] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
      [exec] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      [exec] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
      [exec] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      [exec] at java.lang.Thread.run(Thread.java:619)