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

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

Most upvoted comments

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() or withSession() has a completely broken program.

I will check this issue this week

Hibernate Reactive 1.1.2.Final is 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) Context per 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.