hibernate-reactive: java.lang.IllegalStateException: Session/EntityManager is closed
I’m currently writing a PoC for Hibernate Reactive + Vert.x and encountered an issue when loading data. I see Session/EntityManager is closed whenever I concurrently access the REST API.
I was also able to reproduce the issue in the boiler plate howto application from Vert.x.
Steps to reproduce
- Import and run: https://github.com/vertx-howtos/hibernate-reactive-howto
- Create one product via
POST http://localhost:8080/products
{
"name": "test",
"price": 0
}
- Run
wrk -d 10s -c 20 http://localhost:8080/products/1 - Observe the errors in the server log
Stacktrace
Notes
I have tried to create reproducer tests for this which do not require the use of wrk but so far it has proven hard to reliably reproduce the fault with a test.
Bumping the hibernate reactive dependency in the howto project to 1.1.0.Final did not affect the issue.
The example uses persist(product).call(session::flush) the javadoc states to use #map. I’m not that familiar with Mutiny and not sure whether both equivalent.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 33 (23 by maintainers)
Commits related to this issue
- [Draft] to fix #1073 and https://github.com/quarkusio/quarkus/issues/22433 — committed to Sanne/hibernate-reactive by Sanne 2 years ago
- [#1073] Add integration-tests module With a test to check the creation of multiple sessions from different http request — committed to DavideD/hibernate-reactive by DavideD 2 years ago
- [#1073] Add integration-tests module With a test to check the creation of multiple sessions from different http request — committed to DavideD/hibernate-reactive by DavideD 2 years ago
- [#1073] Add integration-tests module With a test to check the creation of multiple sessions from different http requests — committed to DavideD/hibernate-reactive by DavideD 2 years ago
- [#1073] Add integration-tests module With a test to check the creation of multiple sessions from different http requests — committed to DavideD/hibernate-reactive by DavideD 2 years ago
- Revert "[Draft] to fix #1073 and https://github.com/quarkusio/quarkus/issues/22433" This reverts commit e89a6e4095095ff958ae8593bc5af90e2348202f. — committed to DavideD/hibernate-reactive by DavideD 2 years ago
- [#1073] Add integration-tests module With a test to check the creation of multiple sessions from different http requests — committed to DavideD/hibernate-reactive by DavideD 2 years ago
- Revert "[Draft] to fix #1073 and https://github.com/quarkusio/quarkus/issues/22433" This reverts commit e89a6e4095095ff958ae8593bc5af90e2348202f. — committed to DavideD/hibernate-reactive by DavideD 2 years ago
- [#1073] Add integration-tests module With a test to check the creation of multiple sessions from different http requests — committed to DavideD/hibernate-reactive by DavideD 2 years ago
- [#1073] Add integration-tests module With a test to check the creation of multiple sessions from different http requests — committed to hibernate/hibernate-reactive by DavideD 2 years ago
- [#1073] Add integration-tests module With a test to check the creation of multiple sessions from different http requests — committed to DavideD/hibernate-reactive by DavideD 2 years ago
- [#1073] Add integration-tests module With a test to check the creation of multiple sessions from different http requests — committed to DavideD/hibernate-reactive by DavideD 2 years ago
- [#1073] Add integration-tests module With a test to check the creation of multiple sessions from different http requests — committed to DavideD/hibernate-reactive by DavideD 2 years ago
- [#1073] Add integration-tests module With a test to check the creation of multiple sessions from different http requests — committed to hibernate/hibernate-reactive by DavideD 2 years ago
- [Draft] to fix #1073 and https://github.com/quarkusio/quarkus/issues/22433 — committed to DavideD/hibernate-reactive by Sanne 2 years ago
- [#1073] Add integration-tests module With a test to check the creation of multiple sessions from different http requests — committed to DavideD/hibernate-reactive by DavideD 2 years ago
It should be fixed now. Thanks a lot @Jotschi for letting us know about this issue and patiently wait for a fix.
I’m certain that @Sanne’s right, and this problem was a consequence of #948. The Vert.x context and the Vert.x local context are very different things—kinda like the difference between a static variable and a threadlocal—and if we mix them up then obviously everything goes haywire.
I think we need to prioritize an immediate release just to fix this. Because right now anyone who uses
withTransaction()orwithSession()has a completely broken program.I will check this issue this week
Hibernate Reactive
1.1.2.Finalis available. I’ve sent a PR for Quarkus: https://github.com/quarkusio/quarkus/pull/22898@markusdlugi yes we’ll upgrade Quarkus right away, it will be included in 2.7
I’m preparing a release now
Reopening this issue because the PR doesn’t have a test
@DavideD the difference is that the local context is local to the particular “logical thread” whereas there is one (non-local)
Contextper verticle.@markusdlugi I’ve just tested this and if I revert #1001 everything works
@markusdlugi With mutiny-vertx 2.13.0 and HR 1.0.0.CR9 I don’t see the error.