Concurrent API requests / RollbackException

77 views
Skip to first unread message

Thilo Boehm

unread,
May 28, 2014, 4:51:43 AM5/28/14
to open...@googlegroups.com
Hello OpenOLAT-Team,

if I do multiple concurrent API requests I get the following exception (see below).

I tried different GET requests, e.g.:


Always with the same result. These request are all "read-only", so I don't understand why there is an open transaction.

Is this a bug, or do I have a wrong setup?

I use OpenOLAT 9.4.0 (and older versions) and a MySQL DB (5.5)

Kind regards
Thilo



10:40:21,198  WARN DBImpl:175 - OLAT::WARN ^%^ N1-W20 ^%^ org.olat.core.commons.persistence ^%^ n/a ^%^ n/a ^%^ n/a ^%^ n/a ^%^ Caught Exception in DBImpl.commit. ^%^
>>>stack of 1.cause::javax.persistence.RollbackException: Error while committing the transaction -> 
 at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:92)
 at org.olat.core.commons.persistence.DBImpl.commit(DBImpl.java:722)
 at org.olat.core.commons.persistence.DBImpl.commitAndCloseSession(DBImpl.java:675)
 at org.olat.restapi.security.RestApiLoginFilter.doFilter(RestApiLoginFilter.java:151)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 at org.olat.core.servlets.CrossOriginFilter.doFilter(CrossOriginFilter.java:43)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

>>>stack of 2.cause::javax.persistence.OptimisticLockException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.olat.basesecurity.AuthenticationImpl#3506185] -> 
 at org.hibernate.ejb.AbstractEntityManagerImpl.wrapStaleStateException(AbstractEntityManagerImpl.java:1413)
 at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1329)
 at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310)
 at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:80)
 at org.olat.core.commons.persistence.DBImpl.commit(DBImpl.java:722)
 at org.olat.core.commons.persistence.DBImpl.commitAndCloseSession(DBImpl.java:675)
 at org.olat.restapi.security.RestApiLoginFilter.doFilter(RestApiLoginFilter.java:151)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 at org.olat.core.servlets.CrossOriginFilter.doFilter(CrossOriginFilter.java:43)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

>>>stack of 3.cause::org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.olat.basesecurity.AuthenticationImpl#3506185] -> 
 at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:2521)
 at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3240)
 at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:3138)
 at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3468)
 at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:140)
 at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:395)
 at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:387)
 at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:304)
 at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:349)
 at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56)
 at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1159)

Stéphane Rossé

unread,
May 30, 2014, 5:37:22 AM5/30/14
to open...@googlegroups.com
Hello

Did you pass the cookies to every request or the security token as header of your request? If not, you will authenticate for every request and update some values on the database like the last login date.

I would strongly recommend you to use the cookies after authentication, or to take and pass the security token delivered as an header ( X-OLAT-TOKEN is the name of the header) with your requests.

Best regards
Stéphane Rossé

Thilo Boehm

unread,
May 30, 2014, 7:22:00 AM5/30/14
to open...@googlegroups.com
Hello Stéphane,

I will double check on the cookie again, but I think I use it already.
But the cookie will not help me when I have two concurrent requests from different users.

Regards
Thilo

Stéphane Rossé

unread,
May 30, 2014, 7:33:58 AM5/30/14
to open...@googlegroups.com
Hello

From the stacktrace, I think the issue arise only with concurrent requests of the same user.

Best regards
Stéphane
Reply all
Reply to author
Forward
0 new messages