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

fix #1276 after healthcheck double check success, register async #1290

Merged
merged 7 commits into from
Feb 27, 2024

Conversation

wangchengming666
Copy link
Contributor

@wangchengming666 wangchengming666 commented Feb 23, 2024

方案

rpc-sofa-boot里定义一个否允许延迟服务发布至注册中心的扩展点,然后在sofa-boot-actuator里判断应用的健康状态,通过后再继续注册到注册中心。

修复后验证

demo地址:https://github.com/wangchengming666/sofa-boot-delay-demo
需要在配置里加上这两行

sofa.boot.rpc.enable-auto-publish=true
sofa.boot.rpc.enable-delay-register=true

我的demo验证情况如下,我有一个接口配置了延时10s发布、然后应用启动后会2s循环调用一下,理论上前4~5次都会出现Cannot get the service address of service的异常,之后会正常调用,控制台日志打印如下

2024-02-23 14:50:39.740  INFO 66775 --- [           main] .b.s.StartupSpringApplicationRunListener : Started SOFABoot Demo in 2.556 seconds
com.alipay.sofa.rpc.core.exception.SofaRouteException: RPC-020060001: Cannot get the service address of service [com.example.sofabootprovider.HelloService:1.0], please check the registry log. 
	at com.alipay.sofa.rpc.client.AbstractCluster.noAvailableProviderException(AbstractCluster.java:502)
	at com.alipay.sofa.rpc.client.AbstractCluster.select(AbstractCluster.java:423)
	at com.alipay.sofa.rpc.client.FailoverCluster.doInvoke(FailoverCluster.java:67)
	at com.alipay.sofa.rpc.client.AbstractCluster.invoke(AbstractCluster.java:298)
	at com.alipay.sofa.rpc.client.ClientProxyInvoker.invoke(ClientProxyInvoker.java:83)
	at com.example.sofabootprovider.HelloService_proxy_0.sayHello(HelloService_proxy_0.java)
	at com.example.sofabootprovider.SofaBootProviderApplication.main(SofaBootProviderApplication.java:26)
com.alipay.sofa.rpc.core.exception.SofaRouteException: RPC-020060001: Cannot get the service address of service [com.example.sofabootprovider.HelloService:1.0], please check the registry log. 
	at com.alipay.sofa.rpc.client.AbstractCluster.noAvailableProviderException(AbstractCluster.java:502)
	at com.alipay.sofa.rpc.client.AbstractCluster.select(AbstractCluster.java:423)
	at com.alipay.sofa.rpc.client.FailoverCluster.doInvoke(FailoverCluster.java:67)
	at com.alipay.sofa.rpc.client.AbstractCluster.invoke(AbstractCluster.java:298)
	at com.alipay.sofa.rpc.client.ClientProxyInvoker.invoke(ClientProxyInvoker.java:83)
	at com.example.sofabootprovider.HelloService_proxy_0.sayHello(HelloService_proxy_0.java)
	at com.example.sofabootprovider.SofaBootProviderApplication.main(SofaBootProviderApplication.java:26)
com.alipay.sofa.rpc.core.exception.SofaRouteException: RPC-020060001: Cannot get the service address of service [com.example.sofabootprovider.HelloService:1.0], please check the registry log. 
	at com.alipay.sofa.rpc.client.AbstractCluster.noAvailableProviderException(AbstractCluster.java:502)
	at com.alipay.sofa.rpc.client.AbstractCluster.select(AbstractCluster.java:423)
	at com.alipay.sofa.rpc.client.FailoverCluster.doInvoke(FailoverCluster.java:67)
	at com.alipay.sofa.rpc.client.AbstractCluster.invoke(AbstractCluster.java:298)
	at com.alipay.sofa.rpc.client.ClientProxyInvoker.invoke(ClientProxyInvoker.java:83)
	at com.example.sofabootprovider.HelloService_proxy_0.sayHello(HelloService_proxy_0.java)
	at com.example.sofabootprovider.SofaBootProviderApplication.main(SofaBootProviderApplication.java:26)
com.alipay.sofa.rpc.core.exception.SofaRouteException: RPC-020060001: Cannot get the service address of service [com.example.sofabootprovider.HelloService:1.0], please check the registry log. 
	at com.alipay.sofa.rpc.client.AbstractCluster.noAvailableProviderException(AbstractCluster.java:502)
	at com.alipay.sofa.rpc.client.AbstractCluster.select(AbstractCluster.java:423)
	at com.alipay.sofa.rpc.client.FailoverCluster.doInvoke(FailoverCluster.java:67)
	at com.alipay.sofa.rpc.client.AbstractCluster.invoke(AbstractCluster.java:298)
	at com.alipay.sofa.rpc.client.ClientProxyInvoker.invoke(ClientProxyInvoker.java:83)
	at com.example.sofabootprovider.HelloService_proxy_0.sayHello(HelloService_proxy_0.java)
	at com.example.sofabootprovider.SofaBootProviderApplication.main(SofaBootProviderApplication.java:26)
2024-02-23T14:50:49.799+08:00  WARN 66775 --- [SOFABoot Demo] [           main] io.fury.config.FuryBuilder               : Class registration isn't forced, unknown classes can be deserialized. If the environment isn't secure, please enable class registration by `FuryBuilder#requireClassRegistration(true)` or configure ClassChecker by `ClassResolver#setClassChecker`
2024-02-23T14:50:49.850+08:00  INFO 66775 --- [SOFABoot Demo] [           main] io.fury.Fury                             : Created new fury io.fury.Fury@5c703860
hello world
hello world
hello world
hello world
hello world
hello world
hello world

Copy link

codecov bot commented Feb 23, 2024

Codecov Report

Attention: Patch coverage is 92.00000% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 83.13%. Comparing base (3502092) to head (88b06f7).

Files Patch % Lines
...fa/rpc/boot/container/ProviderConfigContainer.java 89.47% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1290      +/-   ##
============================================
+ Coverage     83.05%   83.13%   +0.08%     
- Complexity     2927     2945      +18     
============================================
  Files           330      331       +1     
  Lines          9625     9659      +34     
  Branches       1164     1168       +4     
============================================
+ Hits           7994     8030      +36     
+ Misses         1126     1120       -6     
- Partials        505      509       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@HzjNeverStop HzjNeverStop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要补充集成测试,可以参考 sofa-boot-smoke-tests-rpc 模块里用例

@sofastack-cla sofastack-cla bot added size/XL and removed size/L labels Feb 27, 2024
Copy link
Contributor

@HzjNeverStop HzjNeverStop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@HzjNeverStop HzjNeverStop merged commit 92efd61 into sofastack:master Feb 27, 2024
5 checks passed
@wangchengming666 wangchengming666 deleted the fix-#1276 branch February 27, 2024 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants