sofa-boot icon indicating copy to clipboard operation
sofa-boot copied to clipboard

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

Open Kunple-w opened this issue 2 years ago • 3 comments

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:

  • Project Version [e.g. SOFA-RPC 1.0.0] :sofa-boot 3.9.1
  • Language Version (e.g. Go 1.13): jdk8
  • OS version (e.g. uname -a): win10
  • IDE version: idea

Additional context

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

Kunple-w avatar Jun 02 '22 12:06 Kunple-w

有简单复现的 demo 吗?

ujjboy avatar Jul 01 '22 08:07 ujjboy

晚点我搭个demo复现一下

Kunple-w avatar Jul 01 '22 09:07 Kunple-w

有简单复现的 demo 吗?

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

Kunple-w avatar Jul 02 '22 04:07 Kunple-w

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

HzjNeverStop avatar Jul 05 '23 07:07 HzjNeverStop