Skip to content
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

Programmatic Cache API does not preserve Vertx Duplicate Context #39515

Closed
markusdlugi opened this issue Mar 18, 2024 · 5 comments · Fixed by #41647
Closed

Programmatic Cache API does not preserve Vertx Duplicate Context #39515

markusdlugi opened this issue Mar 18, 2024 · 5 comments · Fixed by #41647
Labels
Milestone

Comments

@markusdlugi
Copy link
Contributor

Describe the bug

We noticed that using the programmatic cache API via cache.getAsync() leads to the Vertx duplicate context being lost. This can lead to undesired behavior, especially when relying on Hibernate Reactive which stores its session in the context. In our application, we frequently saw the exception java.lang.IllegalStateException: Illegal pop() with non-matching JdbcValuesSourceProcessingState, but of course this will depend on the specific application.

Expected behavior

The context should be preserved.

Actual behavior

The context is lost, leading to problems for applications or modules that rely on the context, e.g. Hibernate Reactive.

How to Reproduce?

https://github.com/markusdlugi/cache-context-reproducer/tree/master

  1. Run the ReproducerTest and observe that the test fails
  2. Remove comment in line 68 in GreetingResource and observe that the test now passes

Output of uname -a or ver

No response

Output of java -version

openjdk version "21.0.2" 2024-01-16 LTS

Quarkus version or git rev

3.8.2

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

Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)

Additional information

A similar bug has already been reported and fixed for the annotation-based cache (#37078), so most likely the same treatment is necessary for the programmatic API.

@markusdlugi markusdlugi added the kind/bug Something isn't working label Mar 18, 2024
@quarkus-bot
Copy link

quarkus-bot bot commented Mar 18, 2024

/cc @gwenneg (cache)

@markusdlugi
Copy link
Contributor Author

Looking closer at #37077, I noticed that the CacheResultInterceptor is actually calling the API in question (cache.getAsync()). So most likely, the fix performed in the interceptor should be moved downwards to the cache API instead of residing in the interceptor, since the programmatic API is actually publicly available and not internal.

@markusdlugi
Copy link
Contributor Author

Pinging @cescoffier since you were the one who implemented the current fix in the CacheResultInterceptor 😄

@cescoffier
Copy link
Member

@markusdlugi Would you like to open a PR to illustrate the change? It makes sense, but I won't have time to do it soon.

@markusdlugi
Copy link
Contributor Author

I'd love to do that but I'm gonna be on vacation soon, so I'd only be able to provide a PR in a couple of weeks. If noone gets around to pick up the topic until that point in time then I'll give it a try.

@quarkus-bot quarkus-bot bot added this to the 3.13 - main milestone Jul 5, 2024
@gsmet gsmet modified the milestones: 3.13 - main, 3.12.2 Jul 9, 2024
@gsmet gsmet modified the milestones: 3.12.2, 3.8.6 Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants