Coder Social home page Coder Social logo

Comments (12)

Ladicek avatar Ladicek commented on July 18, 2024 1

Ah the README in the reproducer has an interesting bit of information: the issue occurs when calling the health check, but when calling any other endpoint, it doesn't. So the links above are indeed very much relevant.

from quarkus.

olivierbeltrandocintoo avatar olivierbeltrandocintoo commented on July 18, 2024 1

I'll clone the reproducer and will investigate properly, but at the first sight, the @ActivateRequestContext annotation on a @RequestScoped bean seems 1. unnecessary, 2. potentially dangerous.

Also, the fact that a request-scoped bean is injected anywhere or what's the scope of the bean that injects it should not matter. A request-scoped bean must be destroyed when the request context terminates.

Hi @Ladicek ,
Sorry, the @ActivateRequestContext is an attempt of workaround (that did not work). Removing it from the sample. Thanks for the help :)

from quarkus.

xstefank avatar xstefank commented on July 18, 2024 1

@olivierbeltrandocintoo There was another issue that collided with this and will be fixed with #38888. With this PR, your reproducer works.

@gsmet I will need to fix it. In SR Health, when you invoke health, we compute a Uni for every major health group, let's say for readiness, we have readinessUni that is saved. On the next invocation, we just return this saved readinessUni once called again so Quarkus can resubscribe and call all end Uni subscriptions (health checks) again. But we save the finding and collecting of health checks into a parent Uni.

from quarkus.

quarkus-bot avatar quarkus-bot commented on July 18, 2024

/cc @Ladicek (smallrye), @geoand (kotlin), @jmartisk (health,smallrye), @phillip-kruger (smallrye), @radcortez (smallrye), @xstefank (health)

from quarkus.

Ladicek avatar Ladicek commented on July 18, 2024

I'll clone the reproducer and will investigate properly, but at the first sight, the @ActivateRequestContext annotation on a @RequestScoped bean seems 1. unnecessary, 2. potentially dangerous.

Also, the fact that a request-scoped bean is injected anywhere or what's the scope of the bean that injects it should not matter. A request-scoped bean must be destroyed when the request context terminates.

from quarkus.

gsmet avatar gsmet commented on July 18, 2024

@Ladicek for your awareness, if you are having a look to this one. There are a few other oddities in progress:

Might not be related but better have the big picture :)

from quarkus.

Ladicek avatar Ladicek commented on July 18, 2024

Thanks @gsmet, I'll keep that in mind!

from quarkus.

xstefank avatar xstefank commented on July 18, 2024

This is caused by manual Uni caching done in SmallRye Health for performance reasons. To correctly handle CDI context propagation, you need to set the quarkus.smallrye-health.context-propagation=true property - https://quarkus.io/guides/smallrye-health#context-propagation-into-the-health-check-invocations. We should add a warning if the user attempts to use CDI without this flag or maybe we should change the default to recreate Unis and just allow to set caching explicitly. WDYT @cescoffier I think that you originally proposed Uni caching in Health.

from quarkus.

cescoffier avatar cescoffier commented on July 18, 2024

Caching is fine if you handle the duplicated context correctly - See #37077

from quarkus.

olivierbeltrandocintoo avatar olivierbeltrandocintoo commented on July 18, 2024

Hello @xstefank , I have tried adding the property quarkus.smallrye-health.context-propagation=true in the application.properties but the issue persists -> Ie. the @PreDestroy is not called.
You can test on the provided reproducer :)

  • add the line in the properties file
  • mvn clean quarkus:dev
  • call http://localhost:8080/q/health/ 3 times, the 4th time it is going to get DOWN -> see logs to check that the message endOfRequest called is missing

from quarkus.

gsmet avatar gsmet commented on July 18, 2024

This is caused by manual Uni caching done in SmallRye Health for performance reasons.

What exactly are you caching?

from quarkus.

olivierbeltrandocintoo avatar olivierbeltrandocintoo commented on July 18, 2024

Hi ! I run the reproducer against Quarkus 3.7.4 that contains the fix #38888 and you are totally right, the @PreDestroy related to the RequestContext is invoked now :) !
And you were also right: the quarkus.smallrye-health.context-propagation=true needs to be set.
Thanks a lot.
Cheers,
Olivier

from quarkus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.