question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hibernate Reactive hangs on insert

See original GitHub issue

Describe 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:closed
  • Created 2 years ago
  • Comments:36 (24 by maintainers)

github_iconTop GitHub Comments

3reactions
stuartwdouglascommented, Apr 14, 2021

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.

1reaction
stuartwdouglascommented, Apr 15, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found