You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I concurrently lock (PESSIMISTIC_WRITE) and modify an Entity with a @Version field, quarkus / hibernate throws a StaleObjectStateException. The relevant example code can be found here. This used to work in Quarkus 2.x.
This can be circumvented by directly locking the Entity with the find call.
I am not sure if this is a Quarkus or Hibernate bug, but I decided to ask here first just in case.
Expected behavior
Tests pass
Actual behavior
Tests fail
jakarta.persistence.OptimisticLockException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) : [root.TestEntity#42]
at org.hibernate.internal.ExceptionConverterImpl.wrapStaleStateException(ExceptionConverterImpl.java:204)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:93)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:162)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:168)
at org.hibernate.internal.SessionImpl.fireRefresh(SessionImpl.java:1306)
at org.hibernate.internal.SessionImpl.refresh(SessionImpl.java:1272)
at org.hibernate.internal.SessionImpl.refresh(SessionImpl.java:1266)
at org.hibernate.internal.SessionImpl.refresh(SessionImpl.java:2583)
at org.hibernate.internal.SessionImpl.refresh(SessionImpl.java:2562)
at io.quarkus.hibernate.orm.runtime.session.TransactionScopedSession.refresh(TransactionScopedSession.java:303)
at org.hibernate.engine.spi.SessionLazyDelegator.refresh(SessionLazyDelegator.java:819)
at org.hibernate.Session_3a974b6a18ac399f675913d732c105426414d370_Synthetic_ClientProxy.refresh(Unknown Source)
at test.MTTest.mtLock(MTTest.java:93)
at test.MTTest_Subclass.mtLock$$superforward(Unknown Source)
at test.MTTest_Subclass$$function$$3.apply(Unknown Source)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:74)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:63)
at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:136)
at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:107)
at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.doIntercept(TransactionalInterceptorRequired.java:38)
at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.intercept(TransactionalInterceptorBase.java:61)
at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.intercept(TransactionalInterceptorRequired.java:32)
at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired_Bean.intercept(Unknown Source)
at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:38)
at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:26)
at test.MTTest_Subclass.mtLock(Unknown Source)
at test.MTTest.lambda$multithreading$0(MTTest.java:49)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) : [root.TestEntity#42]
at org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.checkVersion(AbstractEntityInitializer.java:577)
at org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.upgradeLockMode(AbstractEntityInitializer.java:545)
at org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.resolveEntityInstance(AbstractEntityInitializer.java:529)
at org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.resolveInstance(AbstractEntityInitializer.java:402)
at org.hibernate.sql.results.internal.InitializersList.resolveInstances(InitializersList.java:88)
at org.hibernate.sql.results.internal.StandardRowReader.coordinateInitializers(StandardRowReader.java:110)
at org.hibernate.sql.results.internal.StandardRowReader.readRow(StandardRowReader.java:87)
at org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:179)
at org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:33)
at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.doExecuteQuery(JdbcSelectExecutorStandardImpl.java:362)
at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.executeQuery(JdbcSelectExecutorStandardImpl.java:168)
at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.list(JdbcSelectExecutorStandardImpl.java:93)
at org.hibernate.sql.exec.spi.JdbcSelectExecutor.list(JdbcSelectExecutor.java:31)
at org.hibernate.loader.ast.internal.SingleIdLoadPlan.load(SingleIdLoadPlan.java:144)
at org.hibernate.loader.ast.internal.SingleIdEntityLoaderStandardImpl.load(SingleIdEntityLoaderStandardImpl.java:88)
at org.hibernate.loader.ast.internal.SingleIdEntityLoaderDynamicBatch.load(SingleIdEntityLoaderDynamicBatch.java:76)
at org.hibernate.persister.entity.AbstractEntityPersister.doLoad(AbstractEntityPersister.java:3370)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3351)
at org.hibernate.event.internal.DefaultRefreshEventListener.doRefresh(DefaultRefreshEventListener.java:214)
at org.hibernate.event.internal.DefaultRefreshEventListener.lambda$refresh$0(DefaultRefreshEventListener.java:148)
at org.hibernate.engine.spi.LoadQueryInfluencers.fromInternalFetchProfile(LoadQueryInfluencers.java:79)
at org.hibernate.event.internal.DefaultRefreshEventListener.refresh(DefaultRefreshEventListener.java:146)
at org.hibernate.event.internal.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:70)
at org.hibernate.event.internal.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:50)
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:127)
at org.hibernate.internal.SessionImpl.fireRefresh(SessionImpl.java:1297)
... 24 more
Describe the bug
If I concurrently lock (
PESSIMISTIC_WRITE
) and modify anEntity
with a@Version
field, quarkus / hibernate throws aStaleObjectStateException
. The relevant example code can be found here. This used to work in Quarkus 2.x.This can be circumvented by directly locking the
Entity
with the find call.I am not sure if this is a Quarkus or Hibernate bug, but I decided to ask here first just in case.
Expected behavior
Tests pass
Actual behavior
Tests fail
How to Reproduce?
To reproduce the error:
mtLocking
branch of this repository: https://github.com/mensinda/quarkus-stuff/tree/mtLockingmvn clean verify
To see that it used to work in Quarkus 2.x:
./downgrade.sh
mvn clean verify
Output of
uname -a
orver
Linux 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Output of
java -version
openjdk version "17.0.6" 2023-01-17
GraalVM version (if different from Java)
No response
Quarkus version or git rev
3.0.0.CR2
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f)
Additional information
No response
The text was updated successfully, but these errors were encountered: