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

[Dubbo-5871][Dubbo-5885][Dubbo-5899] Fix nacos registry not work bug since 2.7.6 #5902

Merged
merged 12 commits into from
Mar 31, 2020

Conversation

laddcn
Copy link
Contributor

@laddcn laddcn commented Mar 22, 2020

What is the purpose of the change

Fix nacos registry not work bug mentioned with #5871
, #5885 and #5899

Brief changelog

Verifying this change

Official Demo works out.

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a GITHUB_issue field for the change (usually before you start working on it). Trivial changes like typos do not require a GITHUB issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [Dubbo-XXX] Fix UnknownException when host config not exist #XXX. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Run mvn clean install -DskipTests=false & mvn clean test-compile failsafe:integration-test to make sure unit-test and integration-test pass.
  • If this contribution is large, please follow the Software Donation Guide.

@htynkn htynkn added type/bug Bugs to being fixed type/need-triage Need maintainers to triage labels Mar 23, 2020
@@ -169,12 +170,33 @@ private void doSubscribe(final URL url, final NotifyListener listener, final Set
execute(namingService -> {
for (String serviceName : serviceNames) {
List<Instance> instances = namingService.getAllInstances(serviceName);

//TO FIX bug with https://github.com/apache/dubbo/issues/5885
if (CollectionUtils.isEmpty(instances) && isServiceNamesWithCompatibleMode(url)) {
Copy link
Member

@CodingSinger CodingSinger Mar 23, 2020

Choose a reason for hiding this comment

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

这里有个问题,目前你的更改应该只能解决instances为空的问题,但是没解决不为空的情况下,其中一个serviceName触发实例变动导致的覆盖问题。

Copy link
Contributor Author

@laddcn laddcn Mar 23, 2020

Choose a reason for hiding this comment

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

是的,现在的解决方案存在这个问题。这两个serviceName表示同一个接口,只是因为版本问题产生的两个不同的名字,两个serviceName的instances应该放在一起考虑。我来改下代码

Copy link
Contributor Author

Choose a reason for hiding this comment

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

我增加一个实例管理工具类,实现了相关serviceName的实例一起考虑,避免了覆盖问题,同时对instances为空的情况依然能正常处理,测试功能正常,之前的bug已经解决。

/**
* serviceName -> corresponding serviceName list
*/
private static final Map<String, Set<String>> correspondingServiceNamesMap = Maps.newHashMap();
Copy link
Member

Choose a reason for hiding this comment

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

这里是不是应该考虑并发问题,用ConcurrentHashMap比较合适?

/**
* serviceName -> refreshed instance list
*/
private static final Map<String, List<Instance>> serviceInstanceListMap = Maps.newHashMap();
Copy link
Member

Choose a reason for hiding this comment

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

同下

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已更新

@CodingSinger
Copy link
Member

有个冲突顺便解决下

@laddcn
Copy link
Contributor Author

laddcn commented Mar 24, 2020

有个冲突顺便解决下

已经解决

@codecov-io
Copy link

codecov-io commented Mar 24, 2020

Codecov Report

Merging #5902 into master will decrease coverage by 0.07%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #5902      +/-   ##
============================================
- Coverage     61.31%   61.23%   -0.08%     
- Complexity      498      499       +1     
============================================
  Files           981      982       +1     
  Lines         39106    39147      +41     
  Branches       5620     5628       +8     
============================================
- Hits          23976    23971       -5     
- Misses        12515    12561      +46     
  Partials       2615     2615              
Impacted Files Coverage Δ Complexity Δ
...org/apache/dubbo/registry/nacos/NacosRegistry.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...o/registry/nacos/util/NacosInstanceManageUtil.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...in/java/org/apache/dubbo/common/utils/JVMUtil.java 81.13% <0.00%> (-11.33%) 0.00% <0.00%> (ø%)
...mmon/threadpool/support/AbortPolicyWithReport.java 83.78% <0.00%> (-5.41%) 0.00% <0.00%> (ø%)
...pache/dubbo/remoting/transport/AbstractServer.java 53.75% <0.00%> (-3.75%) 0.00% <0.00%> (ø%)
...ng/transport/dispatcher/all/AllChannelHandler.java 68.96% <0.00%> (ø) 0.00% <0.00%> (ø%)
.../apache/dubbo/remoting/transport/AbstractPeer.java 67.39% <0.00%> (+4.34%) 0.00% <0.00%> (ø%)
...e/dubbo/remoting/transport/netty/NettyChannel.java 60.22% <0.00%> (+4.54%) 21.00% <0.00%> (+1.00%)

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 332e85f...398a94e. Read the comment docs.

@CodingSinger
Copy link
Member

LGTM

@laddcn
Copy link
Contributor Author

laddcn commented Mar 24, 2020

@htynkn Please help me to merge this PR

@laddcn laddcn changed the title [Dubbo-5885][Dubbo-5899] Fix nacos registry not work bug since 2.7.6 [Dubbo-5871][Dubbo-5885][Dubbo-5899] Fix nacos registry not work bug since 2.7.6 Mar 26, 2020
@laddcn
Copy link
Contributor Author

laddcn commented Mar 26, 2020

#5871 seems to occur for the same reason with #5885 and #5889

@laddcn laddcn requested a review from tswstarplanet March 28, 2020 08:49
@mercyblitz mercyblitz merged commit cb12928 into apache:master Mar 31, 2020
vergilyn pushed a commit to vergilyn/dubbo-fork that referenced this pull request Mar 31, 2020
…since 2.7.6 (apache#5902)

* apache#5902

* TO FIX bug with apache#5885

* Avoid instances overwriting problem with different service name

* Avoid duplicated service name which will lead duplicated subscribe

* Use ConcurrentHashMap instead of HashMap

* Format codes

(cherry picked from commit cb12928)
* @return
*/
private boolean isServiceNamesWithCompatibleMode(final URL url) {
if (!isAdminProtocol(url) && createServiceName(url).isConcrete()) {
Copy link
Member

Choose a reason for hiding this comment

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

你好,最近看这块代码觉得有点困惑。为什么判断服务是否需要兼容的时候,要通过createServiceName(url).isConcrete()去判断呢?

@AlbumenJ AlbumenJ mentioned this pull request Nov 17, 2022
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Bugs to being fixed type/need-triage Need maintainers to triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants