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 caching issues with Quarkus 2.2.5.Final

See original GitHub issue

Describe the bug

We have a Kafka consumer method which is annotated with @Blocking. Every time this method receives an event it executes a “list” query using entity manager like select entity from Foo entity and after that it creates a DTO for each one of the returned entities. The first time we receive an event after startup we can see the hibernate sql logs for the “list” query and every subsequent sql log for loading the @OneToMany relationships for every entity when creating the DTO. When a second event arrives we can only see the sql log for the initial “list” query. It seems that hibernate is caching the results between the two events. This happens even if the data where changed in the database between the events leading to loading old data in the DTO. Also the issue happens both in dev and prod modes.

This was working correctly with Quarkus 1.11.2.Final and the issue started when we upgraded to 2.2.5.Final. We are using quarkus-hibernate-orm, quarkus-smallrye-reactive-messaging-kafka, quarkus-jdbc-postgresql and we have no 2LC configured.

Expected behavior

The data should be loaded from the database every time.

Actual behavior

The data are cached between events.

How to Reproduce?

No response

Output of uname -a or ver

Microsoft Windows [Version 10.0.19043.1466]

Output of java -version

java version “11.0.12” 2021-07-20 LTS Java™ SE Runtime Environment 18.9 (build 11.0.12+8-LTS-237) Java HotSpot™ 64-Bit Server VM 18.9 (build 11.0.12+8-LTS-237, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.2.5.FINAL

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)

Additional information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:30 (23 by maintainers)

github_iconTop GitHub Comments

4reactions
mkoubacommented, Feb 4, 2022

^ In other words, it’s rather complicated 😄

2reactions
manovotncommented, Feb 3, 2022

Do we have any time frame on this being fixed?

The cause of this issue is being discussed in https://github.com/quarkusio/quarkus/discussions/23363, so take a look there if you’re interested. In shot, the core problem is that within reactive a CDI request context is captured and “endlessly propagated” and the entity manager is @RequestScoped so it just keep returning the same instance. So this problems spans beyond just Entity Manager.

We have already discussed a possible solution/workaround and I’ll try to create a PR by tomorrow and we’ll see if that fixes more than it breaks 😉 I know there is also a fix planned on Mutiny side but I have no idea how’s that going, @cescoffier might know more.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hibernate caching issues with Quarkus 2.2.5.Final · quarkusio ...
Epic issue lists. Hibernate caching issues with Quarkus 2.2.5.Final #27088. Sign in to view logs · Sign in to view logs ...
Read more >
release - Quarkus
Final released - Jandex 3, new Redis commands, caching annotations for Infinispan ... Final fixes several issues but still does not completely fix ......
Read more >
Developing and compiling your Quarkus applications with ...
To resolve the issue, delete the cached version of your local repository ... mvn com.redhat.quarkus.platform:quarkus-maven-plugin:2.2.5.
Read more >
Hibernate ORM 6.1.6.Final User Guide - Red Hat on GitHub
Entity inheritance and second-level cache mapping; 13.4. ... 2.2.5. Enums. Hibernate supports the mapping of Java enums as basic value types in a...
Read more >
Index (Quarkus - Core - Deployment 2.2.0.Final API) - javadoc.io
RunTimeConfigurationGenerator · CACHE - io.quarkus.deployment. ... IMPORTANT: in most cases, capability build items should not be produced by build steps of ...
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