sofastack / sofa-boot

SOFABoot is a framework that enhances Spring Boot and fully compatible with it, provides readiness check, class isolation, etc.
https://www.sofastack.tech/sofa-boot/docs/Home
Apache License 2.0
4.96k stars 1.26k forks source link

disable-jvm-first=true有时不生效 #978

Closed Kunple-w closed 1 year ago

Kunple-w commented 2 years ago

Describe the bug

在配置com.alipay.sofa.boot.disable-jvm-first=false后,app启动完成后,真正调用时会有一些reference使用jvm,一些使用bolt.

debug发现在ReferenceRegisterHelper#registerReference注册reference时会使用SofaRuntimeProperties#isDisableJvmFirst(SofaRuntimeContext),而SofaRuntimeProperties的判断是根据内部静态变量,而内部静态变量的值的来源是SofaRuntimeConfigurationProperties,由spring回调,正常情况下该流程正常; 但是在一些场景下,如果reference的加载时间早于SofaRuntimeConfigurationProperties,这会导致ReferenceRegisterHelper中读到默认值,也就是false;而reference加载稍晚的,读取到的为true。

To Reproduce

Steps to reproduce the behavior: 看了一下只有ReadinessCheckListener注入了SofaRuntimeConfigurationProperties,如果重写该bean或者不引用health包,应该会稳定复现;

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem. image

Environment:

Additional context

Add any other context about the problem here. 其他几个配置属性应该有类似问题

ujjboy commented 2 years ago

有简单复现的 demo 吗?

Kunple-w commented 2 years ago

晚点我搭个demo复现一下

Kunple-w commented 2 years ago

有简单复现的 demo 吗?

demo https://github.com/Kunple-w/sofa-disable-jvm-first-not-work

HzjNeverStop commented 1 year ago

最新版本已经优化了相关逻辑