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

增加redisRegistry consumer侧的服务探活逻辑 #7929

Merged
merged 14 commits into from Jun 10, 2021

Conversation

@lkxiaolou
Copy link

@lkxiaolou lkxiaolou commented May 31, 2021

增加redisRegistry consumer侧的服务探活逻辑

目前redisRegistry的实现中,provider异常(未执行注销逻辑,如被kill -9)下线,只在monitoring center存在的情况下会对过期的provider进行下线操作,这有两个缺点:

  • monitoring center不一定会部署
  • 它的实现使用了keys,会阻塞redis; -> 更新:最新版本使用scan扫描,不会阻塞redis

解法:

在consumer侧对订阅到的服务进行检查,每隔 1/2 session 时间检查provider是否过期,如果过期,对它执行doNotify,即重新从redis获取最新数据,验证过期时间。

验证:

  • 旧逻辑:使用redisRegistry,启动2个provider,1个consumer,对其中1个provider执行kill -9,consumer调用会有部分请求报错。
    image

  • 新逻辑:使用redisRegistry,启动2个provider,1个consumer,对其中1个provider执行kill -9,consumer会在1/2 session时间(默认30s,可配置)内将有问题的provider踢掉。
    image

notify日志可以看出只有1个provider了

2021-05-31 10:52:45,312 [DubboRegistryExpireTimer-thread-1] INFO  org.apache.dubbo.registry.redis.RedisRegistry (RedisRegistry.java:472) -  [DUBBO] redis notify: /dubbo/com.didichuxing.basic.api.MyDemoService/providers = [dubbo://127.0.0.1:20880/com.didichuxing.basic.api.MyDemoService?anyhost=true&application=ddog-my-demo-p0&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=com.didichuxing.basic.api.MyDemoService&methods=call&owner=roshilikang&pid=1543&release=2.7.6&side=provider&threads=500&timestamp=1622429433943], dubbo version: 2.7.8-SNAPSHOT, current host: 172.23.232.133
xukefu and others added 6 commits Dec 21, 2020
@AlbumenJ
Copy link
Member

@AlbumenJ AlbumenJ commented Jun 1, 2021

Would you please add some ut cases to verify this PR?

@lkxiaolou
Copy link
Author

@lkxiaolou lkxiaolou commented Jun 2, 2021

Would you please add some ut cases to verify this PR?

done

@codecov-commenter
Copy link

@codecov-commenter codecov-commenter commented Jun 2, 2021

Codecov Report

Merging #7929 (2037fc5) into master (75cda93) will increase coverage by 0.69%.
The diff coverage is 93.33%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #7929      +/-   ##
============================================
+ Coverage     60.46%   61.16%   +0.69%     
+ Complexity      544      491      -53     
============================================
  Files          1089     1090       +1     
  Lines         43845    43965     +120     
  Branches       6404     6427      +23     
============================================
+ Hits          26509    26889     +380     
+ Misses        14370    14095     -275     
- Partials       2966     2981      +15     
Impacted Files Coverage Δ
...org/apache/dubbo/registry/redis/RedisRegistry.java 58.42% <93.33%> (+9.41%) ⬆️
...org/apache/dubbo/remoting/zookeeper/EventType.java 0.00% <0.00%> (-61.91%) ⬇️
.../configcenter/support/zookeeper/CacheListener.java 28.57% <0.00%> (-42.86%) ⬇️
...pport/zookeeper/ZookeeperDynamicConfiguration.java 57.14% <0.00%> (-25.72%) ⬇️
...apache/dubbo/registry/client/ServiceDiscovery.java 24.24% <0.00%> (-18.19%) ⬇️
...in/java/org/apache/dubbo/common/utils/JVMUtil.java 81.13% <0.00%> (-11.33%) ⬇️
...ng/transport/dispatcher/all/AllChannelHandler.java 82.75% <0.00%> (-6.90%) ⬇️
...n/java/org/apache/dubbo/common/utils/LFUCache.java 80.86% <0.00%> (-5.42%) ⬇️
...ing/zookeeper/support/AbstractZookeeperClient.java 74.68% <0.00%> (-5.07%) ⬇️
...fig/configcenter/TreePathDynamicConfiguration.java 85.71% <0.00%> (-2.86%) ⬇️
... and 79 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 75cda93...2037fc5. Read the comment docs.

@lkxiaolou
Copy link
Author

@lkxiaolou lkxiaolou commented Jun 4, 2021

@AlbumenJ @xukefu 1 workflow awaiting approval

@xukefu
Copy link

@xukefu xukefu commented Jun 4, 2021

I don't know why you submitted CompatibleTypeUtils,this class you are currently submitting is the old one, and the new one has been merged into the master. If you merge your current PR directly, it will overwrite the optimized code and cause compilation errors.

@lkxiaolou
Copy link
Author

@lkxiaolou lkxiaolou commented Jun 4, 2021

I don't know why you submitted CompatibleTypeUtils,this class you are currently submitting is the old one, and the new one has been merged into the master. If you merge your current PR directly, it will overwrite the optimized code and cause compilation errors.

File changed only RedisRegistry and RedisRegistryTest

@lkxiaolou lkxiaolou requested a review from AlbumenJ Jun 8, 2021
@lkxiaolou lkxiaolou requested a review from chickenlj Jun 8, 2021
@chickenlj chickenlj merged commit ebd9b4b into apache:master Jun 10, 2021
10 checks passed
@chickenlj chickenlj added this to the 2.7.13 milestone Jun 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants