| When a post-transaction synchronization fails, we get a stack trace looking like this:
org.hibernate.AssertionFailure: Exception releasing cache locks
at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1915)
at org.hibernate.search.util.impl.test.FutureAssert.getNow(FutureAssert.java:135)
at org.hibernate.search.util.impl.test.FutureAssert.isSuccessful(FutureAssert.java:78)
at org.hibernate.search.util.impl.test.FutureAssert.isSuccessful(FutureAssert.java:68)
... 27 more
Caused by: org.hibernate.AssertionFailure: Exception releasing cache locks
at org.hibernate.engine.spi.ActionQueue$AfterTransactionCompletionProcessQueue.afterTransactionCompletion(ActionQueue.java:990)
at org.hibernate.engine.spi.ActionQueue.afterTransactionCompletion(ActionQueue.java:513)
at org.hibernate.internal.SessionImpl.afterTransactionCompletion(SessionImpl.java:2427)
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.afterTransactionCompletion(JdbcCoordinatorImpl.java:453)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.afterCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:203)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$400(JdbcResourceLocalTransactionCoordinatorImpl.java:40)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:283)
at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101)
at org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.withinTransaction(OrmUtils.java:57)
at org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.lambda$withinTransaction$1(OrmUtils.java:42)
at org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.withinSession(OrmUtils.java:27)
at org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.withinTransaction(OrmUtils.java:40)
at org.hibernate.search.integrationtest.mapper.orm.automaticindexing.AutomaticIndexingSynchronizationStrategyIT.lambda$runTransactionInDifferentThread$2(AutomaticIndexingSynchronizationStrategyIT.java:384)
at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1626)
at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1618)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Suppressed: org.hibernate.TransactionException: Cannot rollback transaction in current status [COMMITTED]
at org.hibernate.engine.transaction.internal.TransactionImpl.rollback(TransactionImpl.java:136)
at org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.withinTransaction(OrmUtils.java:61)
... 10 more
Caused by: org.hibernate.HibernateException: Error while indexing in Hibernate Search (after transaction completion)
at org.hibernate.search.mapper.orm.session.impl.SynchronizationAdapter.doAfterTransactionCompletion(SynchronizationAdapter.java:70)
at org.hibernate.engine.spi.ActionQueue$AfterTransactionCompletionProcessQueue.afterTransactionCompletion(ActionQueue.java:983)
... 18 more
Caused by: ...
This happens in particular when an exception is thrown upon indexing in Hibernate Search. I think there are two problems with this behavior:
- org.hibernate.AssertionFailure is supposed to indicate "a possible bug in Hibernate". There's nothing here that indicates a bug. In fact, in the case of Hibernate Search, this could simply happen if the connection to Elasticsearch breaks suddenly.
- "Exception releasing cache locks" seems related to a specific use of transaction synchronizations
I think we should rather use a HibernateException with a more generic message, such as "Exception after transaction completion: <message of the exception>" |