tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dain Sundstrom <d...@iq80.com>
Subject Re: OptimisticLockException
Date Wed, 19 Mar 2008 02:07:12 GMT
This is one of the more confusing parts of the JPA spec.  Although the  
API looks like you should be getting a pessimistic write lock (select  
for update in oracle) when you call that method, you actually only get  
an optimistic lock according to the spec.  In order to get a  
pessimistic lock, you need to turn on the OpenJPA pessimistic lock  
code by adding this flag to the persistence unit:

	openjpa.LockManager=pessimistic

This only works if you are using a database that supports pessimistic  
lock.  The default database in OpenEJB hsqldb doesn't so you'll have  
to use something like Derby, H2, Oracle, mySql or DB2.

-dain

On Mar 17, 2008, at 11:47 PM, the666pack wrote:

>
> Hello,
>
> so i try to test the geronimo 2.0.2 server how it handles concurrent  
> delete
> requests. i
> start quite low with 5 concurrent users trying to delete some values  
> from
> the database. the problem is that i keep getting the error mentioned  
> in the
> subject. the more concurrent users i schedule, the more errors i get  
> until
> about 30 concurrent users the performance levels off quite low. the  
> thing i
> do in my code is removing a persistent entity:
>
>          // em.lock(director,LockModeType.WRITE); //optimistic lock
> exception??????
>           em.remove(director);
>           //em.flush();                 //because of optimistic lock
> exception
>           deleted++;
>
> i also tried with the help of the commented out lines, but without a
> significant performance increase, here is the error log, maybe  
> someone could
> help, THANK YOU!
>
> [exec] Caused by: <openjpa-1.0.0-r420667:568756 nonfatal store error>
> org.apache.openjpa.persistence.OptimisticLockException: An  
> optimistic lock
> violation was detected when flushing object instance
> "vt.bean.entity.Director-1192302" to the data store.  This indicates  
> that
> the object was concurrently modified in another transaction.
>    [exec] FailedObject: vt.bean.entity.Director-1192302
>    [exec]     at
> org 
> .apache 
> .openjpa 
> .jdbc 
> .kernel 
> .PreparedStatementManagerImpl 
> .flushInternal(PreparedStatementManagerImpl.java:101)
>    [exec]     at
> org 
> .apache 
> .openjpa 
> .jdbc 
> .kernel 
> .PreparedStatementManagerImpl 
> .flush(PreparedStatementManagerImpl.java:73)
>    [exec]     at
> org 
> .apache 
> .openjpa 
> .jdbc 
> .kernel 
> .OperationOrderUpdateManager 
> .flushPrimaryRow(OperationOrderUpdateManager.java:162)
>    [exec]     at
> org 
> .apache 
> .openjpa 
> .jdbc 
> .kernel 
> .OperationOrderUpdateManager.flush(OperationOrderUpdateManager.java: 
> 89)
>    [exec]     at
> org 
> .apache 
> .openjpa 
> .jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java: 
> 89)
>    [exec]     at
> org 
> .apache 
> .openjpa 
> .jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java: 
> 72)
>    [exec]     at
> org 
> .apache 
> .openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:514)
>    [exec]     at
> org 
> .apache 
> .openjpa 
> .kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:130)
>    [exec]     ... 42 more
>    [exec] NestedThrowables:
>    [exec] <openjpa-1.0.0-r420667:568756 nonfatal store error>
> org.apache.openjpa.persistence.OptimisticLockException: An  
> optimistic lock
> violation was detected when flushing object instance
> "vt.bean.entity.Director-1192302" to the data store.  This indicates  
> that
> the object was concurrently modified in another transaction.
>    [exec] FailedObject: vt.bean.entity.Director-1192302
>    [exec]     at
> org 
> .apache 
> .openjpa 
> .jdbc 
> .kernel 
> .PreparedStatementManagerImpl 
> .flushInternal(PreparedStatementManagerImpl.java:101)
>    [exec]     at
> org 
> .apache 
> .openjpa 
> .jdbc 
> .kernel 
> .PreparedStatementManagerImpl 
> .flush(PreparedStatementManagerImpl.java:73)
>    [exec]     at
> org 
> .apache 
> .openjpa 
> .jdbc 
> .kernel 
> .OperationOrderUpdateManager 
> .flushPrimaryRow(OperationOrderUpdateManager.java:162)
>    [exec]     at
> org 
> .apache 
> .openjpa 
> .jdbc 
> .kernel 
> .OperationOrderUpdateManager.flush(OperationOrderUpdateManager.java: 
> 89)
>    [exec]     at
> org 
> .apache 
> .openjpa 
> .jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java: 
> 89)
>    [exec]     at
> org 
> .apache 
> .openjpa 
> .jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java: 
> 72)
>    [exec]     at
> org 
> .apache 
> .openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:514)
>    [exec]     at
> org 
> .apache 
> .openjpa 
> .kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:130)
>    [exec]     at
> org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1946)
>    [exec]     at
> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1844)
>    [exec]     at
> org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1615)
>    [exec]     at
> org 
> .apache.openjpa.kernel.DelegatingBroker.flush(DelegatingBroker.java: 
> 973)
>    [exec]     at
> org 
> .apache 
> .openjpa.persistence.EntityManagerImpl.flush(EntityManagerImpl.java: 
> 488)
>    [exec]     at
> vt.bean.stateless.DeleteDataBean.removeDirectors(DeleteDataBean.java: 
> 115)
>    [exec]     at sun.reflect.GeneratedMethodAccessor175.invoke(Unknown
> Source)
>    [exec]     at
> sun 
> .reflect 
> .DelegatingMethodAccessorImpl 
> .invoke(DelegatingMethodAccessorImpl.java:25)
>    [exec]     at java.lang.reflect.Method.invoke(Method.java:597)
>    [exec]     at
> org.apache.openejb.core.interceptor.ReflectionInvocationContext 
> $Invocation.invoke(ReflectionInvocationContext.java:146)
>    [exec]     at
> org 
> .apache 
> .openejb 
> .core 
> .interceptor 
> .ReflectionInvocationContext 
> .proceed(ReflectionInvocationContext.java:129)
>    [exec]     at
> org 
> .apache 
> .openejb 
> .core.interceptor.InterceptorStack.invoke(InterceptorStack.java:67)
>    [exec]     at
> org 
> .apache 
> .openejb 
> .core.stateless.StatelessContainer._invoke(StatelessContainer.java: 
> 203)
>    [exec]     at
> org 
> .apache 
> .openejb 
> .core.stateless.StatelessContainer.invoke(StatelessContainer.java:165)
>    [exec]     at
> org 
> .apache 
> .openejb 
> .core 
> .ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java: 
> 223)
>    [exec]     at
> org 
> .apache 
> .openejb 
> .core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:77)
>    [exec]     at
> org 
> .apache 
> .openejb 
> .core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:245)
>    [exec]     at
> org 
> .apache 
> .openejb 
> .util 
> .proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
>    [exec]     at $Proxy23.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:806)
>    [exec]     at
> org 
> .apache 
> .jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
>    [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:806)
>    [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 
> .apache 
> .catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java: 
> 230)
>    [exec]     at
> org 
> .apache 
> .catalina.core.StandardContextValve.invoke(StandardContextValve.java: 
> 175)
>    [exec]     at
> org 
> .apache 
> .geronimo 
> .tomcat.valve.DefaultSubjectValve.invoke(DefaultSubjectValve.java:56)
>    [exec]     at
> org.apache.geronimo.tomcat.GeronimoStandardContext 
> $SystemMethodValve.invoke(GeronimoStandardContext.java:353)
>    [exec]     at
> org 
> .apache 
> .geronimo 
> .tomcat 
> .valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java: 
> 47)
>    [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 
> .apache 
> .catalina.core.StandardEngineValve.invoke(StandardEngineValve.java: 
> 109)
>    [exec]     at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java: 
> 563)
>    [exec]     at
> org 
> .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java: 
> 261)
>    [exec]     at
> org 
> .apache.coyote.http11.Http11Processor.process(Http11Processor.java: 
> 844)
>    [exec]     at
> org.apache.coyote.http11.Http11Protocol 
> $Http11ConnectionHandler.process(Http11Protocol.java:581)
>    [exec]     at
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java: 
> 447)
>    [exec]     at java.lang.Thread.run(Thread.java:619)
>    [exec] 07:12:28,046 ERROR [[jsp]] Servlet.service() for servlet jsp
> threw exception
>    [exec] java.lang.Exception: <openjpa-1.0.0-r420667:568756 nonfatal
> store error> org.apache.openjpa.persistence.OptimisticLockException:  
> An
> optimistic lock violation was detected when flushing object instance
> "vt.bean.entity.Director-1192302" to the data store.  This indicates  
> that
> the object was concurrently modified in another transaction.
>    [exec] FailedObject: vt.bean.entity.Director-1192302
>    [exec]     at
> org 
> .apache 
> .openjpa.util.Exceptions.replaceNestedThrowables(Exceptions.java:242)
>    [exec]     at
> org 
> .apache 
> .openjpa 
> .persistence 
> .OptimisticLockException.writeObject(OptimisticLockException.java:101)
>    [exec]     at sun.reflect.GeneratedMethodAccessor179.invoke(Unknown
> Source)
>    [exec]     at
> sun 
> .reflect 
> .DelegatingMethodAccessorImpl 
> .invoke(DelegatingMethodAccessorImpl.java:25)
>    [exec]     at java.lang.reflect.Method.invoke(Method.java:597)
>    [exec]     at
> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java: 
> 945)
>    [exec]     at
> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
> 1461)
>    [exec]     at
> java 
> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
> 1392)
>    [exec]     at
> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
>    [exec]     at
> java 
> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java: 
> 1509)
>    [exec]     at
> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
> 1474)
>    [exec]     at
> java 
> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
> 1392)
>    [exec]     at
> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
>    [exec]     at
> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
>    [exec]     at
> org 
> .apache 
> .openejb 
> .core.ivm.BaseEjbProxyHandler.copyObj(BaseEjbProxyHandler.java:508)
>    [exec]     at
> org 
> .apache 
> .openejb 
> .core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:250)
>    [exec]     at
> org 
> .apache 
> .openejb 
> .util 
> .proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
>    [exec]     at $Proxy23.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:806)
>    [exec]     at
> org 
> .apache 
> .jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
>    [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:806)
>    [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 
> .apache 
> .catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java: 
> 230)
>    [exec]     at
> org 
> .apache 
> .catalina.core.StandardContextValve.invoke(StandardContextValve.java: 
> 175)
>    [exec]     at
> org 
> .apache 
> .geronimo 
> .tomcat.valve.DefaultSubjectValve.invoke(DefaultSubjectValve.java:56)
>    [exec]     at
> org.apache.geronimo.tomcat.GeronimoStandardContext 
> $SystemMethodValve.invoke(GeronimoStandardContext.java:353)
>    [exec]     at
> org 
> .apache 
> .geronimo 
> .tomcat 
> .valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java: 
> 47)
>    [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 
> .apache 
> .catalina.core.StandardEngineValve.invoke(StandardEngineValve.java: 
> 109)
>    [exec]     at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java: 
> 563)
>    [exec]     at
> org 
> .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java: 
> 261)
>    [exec]     at
> org 
> .apache.coyote.http11.Http11Processor.process(Http11Processor.java: 
> 844)
>    [exec]     at
> org.apache.coyote.http11.Http11Protocol 
> $Http11ConnectionHandler.process(Http11Protocol.java:581)
>    [exec]     at
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java: 
> 447)
>    [exec]     at java.lang.Thread.run(Thread.java:619)
> -- 
> View this message in context: http://www.nabble.com/OptimisticLockException-tp16114674p16114674.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>


Mime
View raw message