hibernate-reactive
hibernate-reactive copied to clipboard
Make the illegal pop message more user friendly
Users can sometime see this error:
org.hibernate.HibernateException: java.util.concurrent.CompletionException: java.lang.IllegalStateException: Illegal pop() with non-matching JdbcValuesSourceProcessingState
Usually, when they are sharing the session in different streams. We could add some info to the error message.
Hibernate ORM is generating this error. I've created an issue for it: https://hibernate.atlassian.net/browse/HHH-16869
Hi were you able to find any workaround related to this issue?
What do you mean? This error means that the session is not used correctly. The user needs to change something.
This issue refers only to the error message
Ohh Alright, I have started getting this exception intermittently when using hibernate 6.2.2. I am still unable to find how it's happening because it's occurring once in > 1000 executions.
It happens when the same session instance is used in parallel by different threads or different CompletionStage or Uni.
Well... I guess it could also be a bug. In any case we would need to see some code to be able to help. Feel free to create a separate issue with more details.
Well... I guess it could also be a bug. In any case we would need to see some code to be able to help. Feel free to create a separate issue with more details.
Hi I have created this issue.
https://hibernate.atlassian.net/browse/HHH-16903
Can you please have a look into it?
I've run into this error as well. Reproduces on my system(Using Mutiny.SessionFactory):
final var result = sessionFactory
.withTransaction(session -> {
Uni.combine()
.all()
.unis(session.find(Item1.class, id), session.find(Item2.class, id2))
.asTuple();
}).await().indefinitely();
I know that this is a perfect example of what NOT to do in Hibernate Reactive 😊, but the error message could be a lot friendlier.
This is an error thrown by Hibernate ORM. I've opened an issue some time ago about it: https://hibernate.atlassian.net/browse/HHH-16869
In short, this is not the only situation where this message is thrown and this is the best that can be done at the moment. I'm going to close this issue, eventually we might be able to solve the issue by not having to throw the error in the first place.
happend to me while using parallel streams... when i tested allone everything worked well.... but then there were two testers at the same time ^^
I had this case: using 6.2.18.Final
entity X.getY() relates OneToOne to entity Y Y has a String property z with a setter that throws exception of you Y.setZ(null) The database happened to have Y's with z=null
Then "SELECT x from X x" fails with this "illegal pop() with non-matching JdbcValuesSourceProcessingState"
The actual problem (that setZ throwed some Exception) was not logged or present in the stacktrace at all.
So it appears, then hibernate n+1-loads the Y's after having loaded a list of X'es, when calling X.setZ(null) throws exception, this exception gets swallowed, and eventually "illegal pop() with non-matching JdbcValuesSourceProcessingState" is thrown instead.
I you could provide a test case I can have a look at it. Does it also happen with the latest Hibernate Reactive (2.2.1.Final) with Hibernate ORM 6.4.1.Final?
For other users who are upgrading to Hibernate 6 and facing this issue, the below hint from @DavideD was a great time saver for us.
It happens when the same session instance is used in parallel by different threads or different CompletionStage or Uni.
We were indeed using the same session concurrently by using Flux.merge, which did not raise any exceptions with Hibernate 5. Changing to a sequential subscriber like Flux.concat fixed it.
Our Hibernate version is 6.2.13.Final.
The exception message is a bit cryptic, so I hope this is helpful for other users.
I spent hours trying to debug an issue caused by this. Changing the error message would definitely help future developers.
I'm leaving this here for future people who may have this problem. In my case I was using parallelStream and getting this error, I see that in the documentation https://hibernate.org/reactive/documentation/2.4/reference/html_single/#_sessions_and_vert_x_contexts this is specified "The Hibernate session is not thread-safe (nor "stream-safe"), ..."
@DavideD Hibernate ORM has a way to customize the exception converter. I wonder if we could use that to "augment" the error message, since it's clear that lots of people are struggling with this.
I will have a look.