quarkus: Hibernate Reactive hangs on insert
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.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 36 (24 by maintainers)
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.