Hibernate Reactive hangs on insert
See original GitHub issueDescribe the bug
Hibernate reactive hangs when inserting, the sequence generator stops returning numbers and requests just hang.
To Reproduce
Take the hibernate reactive quickstart, and remove the unique constraint for the name field (it will still reproduce even with this, this just simplifies things).
Then run wrk -s post.lua http://localhost:8080/fruits
where post.lua is:
wrk.method = "POST"
wrk.body = "{\"name\": \"fruit\"}"
wrk.headers["Content-Type"] = "application/json"
Everything will hang very quickly, locally I set breapoints in BlockingIdentifierGenerator and I see the following output:
Breakpoint reached at org.hibernate.reactive.id.impl.BlockingIdentifierGenerator.generate(BlockingIdentifierGenerator.java:69)
Breakpoint reached at org.hibernate.reactive.id.impl.BlockingIdentifierGenerator.lambda$generate$1(BlockingIdentifierGenerator.java:76)
Breakpoint reached at org.hibernate.reactive.id.impl.BlockingIdentifierGenerator.generate(BlockingIdentifierGenerator.java:69)
Breakpoint reached at org.hibernate.reactive.id.impl.BlockingIdentifierGenerator.lambda$generate$1(BlockingIdentifierGenerator.java:76)
Breakpoint reached at org.hibernate.reactive.id.impl.BlockingIdentifierGenerator.generate(BlockingIdentifierGenerator.java:69)
Basically the 3rd time generate() is called and attempts to allocate more numbers the call just never returns.
Issue Analytics
- State:
- Created 2 years ago
- Comments:36 (24 by maintainers)
Top Results From Across the Web
How to properly batch insert using Quarkus reactive hibernate ...
How to properly batch insert using Quarkus reactive hibernate with panache - Stack Overflow. Stack Overflow for Teams – Start collaborating and ...
Read more >Using Hibernate Reactive - Quarkus
Hibernate Reactive is a reactive API for Hibernate ORM, supporting non-blocking database drivers and a reactive style of interaction with the database.
Read more >Hibernate Reactive - Getting Started Guide - Thorben Janssen
One way to do that is to use Hibernate Reactive. It's based on Vert.X and implements the well-known concepts of JPA and Hibernate...
Read more >3 Common Hibernate Performance Issues in Your Log
A lot of Hibernate performance issues can be found in the log file. In this article, I show you 3 commons ones and...
Read more >Hibernate hangs when i try to insert a Blob multiple times
I found a work around for the problem. I found that if i commit the session after inovking session.save() for each record it...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Also it is a pretty serious issue, as even a tiny bit of load break HR and then inserts just stop working, and I am not 100% sure that my analysis is correct because I did not spend a lot of time on it. It is definitely hanging in the ID generator under even tiny amounts of load, but I have not verified that my thread theory is correct, it could be something else.
Ok, the bug is actually ridiculously simple. When the queue is processed ‘session’ refers to the session that just generated the ID, not the session that is asking for the ID. Because we call result.complete() earlier if this finishes off the request it can close the EM, so you are calling generate with a closed session.