-
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
"could not prepare statement" ("Connection is closed") when reusing a session for another transaction after a rollback #16463
Comments
I opened https://hibernate.atlassian.net/browse/HHH-14557 to resolve the problem upstream. In Quarkus itself, we mostly need to add a test. I suspect the mass indexing test we currently have uses a trivial dataset, resulting in only processing a single batch when mass indexing... |
I'm not convinced that this is a good idea. There is wide-spread cargo-cult about this pattern but as far as I know it's better to still commit. |
@Sanne Glad to hear that: hibernate/hibernate-search#2545. That was very old code, I think :) |
hoo yes I remember some discussions about that :) +1 to just commit, but it's worth remembering the reason it used to be like that (as far as I remember now) : users might have dodgy code in their entities which makes it flagged dirty just because we've loaded it. Make sure to disable flushing. |
@suchwerk a workaround is coming in 1.13.2.Final! |
Also, an actual fix was merged into Hibernate ORM: hibernate/hibernate-orm#3918 This issue should be completely fixed in Quarkus once we upgrade to ORM 5.4.31.Final or 5.5.0.Final (not released yet). |
Describe the bug
This sequence of actions causes ORM to reuse a connection that was closed implicitly by Agroal, ultimately throwing an exception:
This happens in particular when mass indexing in Hibernate Search, because Hibernate Search rolls back transactions instead of committing them, since it only reads data.
Expected behavior
No exception. ORM should close connections on rollback, at least with the default connection handling mode.
Actual behavior
Mass indexing fails after the first batch, with errors like this:
To Reproduce
Originally reported by @suchwerk: thanks to him!
Reproducer (in Quarkus): https://github.com/suchwerk/quarkus-hibernate-search-massindexer
You'll need to start an Elasticsearch container, then run the tests:
Configuration
N/A
Screenshots
N/A
Environment (please complete the following information):
Quarkus version or git rev
1.13.1.Final
Probably applies to 1.13.x only, since we switched the connection handling mode in 1.13.0.Final.
The text was updated successfully, but these errors were encountered: