-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hibernate Reactive Session/EntityManager is closed #22433
Comments
/cc @DavideD, @Sanne, @gavinking |
@Sanne If you need more information or if I can help with something, please don't hesitate to ask. |
At first glance, I'd say it's related to this other issue: hibernate/hibernate-reactive#1073 |
Indeed. |
Nice, I was able to reproduce it now - indeed it happens reliably. Hopefully it's downhill from here but it still seems complex :) |
@gwenneg Could you try this branch, please? https://github.com/DavideD/hibernate-reactive/tree/1073 |
I should be able to test that in a couple hours. |
Which Quarkus version should I use to test your branch @DavideD? I tried with 2.5.4.Final and 2.6.2.Final but the application won't start because of this:
|
@gwenneg We are still looking into this. It seems that the two issues weren't related after all |
This reverts commit e89a6e4.
This reverts commit e89a6e4.
We have just released a new Hibernate Reactive version ( |
This may not be entirely fixed. We just had the same exception on our stage environment with Quarkus 2.6.3.Final. I'll try to reproduce it later today. |
Was this fixed in the end? |
I think so. Unless you have a usecase that causing the exception again. |
Yes it was fixed. |
I'm running into an issue where this exception is thrown when multiple calls are made to the DB either in rapid succession or concurrently (a GraphQL data fetcher fetching children entities), but I'm not sure it's something I'm not doing right. Are there docs on how to avoid this exception? |
This exception happens when trying to use a session that's been closed before time. I don't think we can help without seeing some code. |
@DavideD I was able to solve my problem by using In the last sentence I put "if" in quotes because I'm not sure if they're run on the same reactive stream. |
If you could show an example of the code you are working with, we might be more helpful. |
@DavideD I created a repo with a code example: https://github.com/LajosPolya/GraphQL-Hibernate-Reactive To give you a quick description. I have defined a Parent entity to have a one-many relationship with a Child entity. If more than one Parents and Children exists and I try to query for the Children after querying for the Parents then the exception is throw. |
Thanks @LajosPolya. If you could create a test class that I can run, it would save a lot of time. By the way, any particular reason for using MySQL 5.7? We don't test that version. |
I'll try to create a test by today or tomorrow. The other project I'm working on uses MySQL 5.7 (the version is out of my hands) and I wanted to replicate the environment in this demo. |
@DavideD I added a test case. The test case populates all the data it needs so as long as it connects to a DB with the correct schema you should be good to go. Should this conversation be transferred to hibernate/hibernate-reactive#1073 since I'm not using Quarkus? |
I want to see the error before deciding where/if to open an issue |
Thanks @LajosPolya, I can see the error now. I will try to figure out what's going on and let you know |
I'm not familiar with any of the technologies you are using and it's not easy to debug all the layers, but I think One solution for this would be not to use
Basically, for each query we create a new session and make sure that's closed at the end. |
Thanks for the code example, this fixed all of my issues!
Yes, the queries to the children will get called in parallel.
But how come this is the case? If a session is still being used by the second query then why is the first query able to close it?
Can you explain/point me to documentation on how the |
The session gets closed at the end of the The session is not thread-safe. There are no check in place to make sure that it doesn't get closed if somebody else is still using it. Also,
It's part of the Mutiny API: https://github.com/smallrye/smallrye-mutiny/blob/main/implementation/src/main/java/io/smallrye/mutiny/Uni.java#L549 It's similar to a finally block:
|
Describe the bug
The following bug appeared at some point between
2.4.0.Final
and2.5.1.Final
.When used in a highly concurrent context, Hibernate Reactive can sometimes throw this exception:
Expected behavior
No response
Actual behavior
No response
How to Reproduce?
Reproducer: https://github.com/quarkusio/quarkus-quickstarts/tree/main/hibernate-reactive-quickstart
Steps to reproduce the behavior:
2.4.0.Final
and2.5.4.Final
Output of
uname -a
orver
Linux glepage.remote.csb 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 8 13:30:15 EST 2021 x86_64 x86_64 x86_64 GNU/Linux
Output of
java -version
openjdk version "11.0.13" 2021-10-19 LTS
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.5.4.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
No response
The text was updated successfully, but these errors were encountered: