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

[Bug] The actual number of connections established is twice what I configured #14129

Open
3 of 4 tasks
lpcy opened this issue Apr 25, 2024 · 3 comments
Open
3 of 4 tasks
Labels
component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage

Comments

@lpcy
Copy link

lpcy commented Apr 25, 2024

Pre-check

  • I am sure that all the content I provide is in English.

Search before asking

  • I had searched in the issues and found no similar issues.

Apache Dubbo Component

Java SDK (apache/dubbo)

Dubbo Version

Dubbo Java 3.2.5, JDK 1.8, Linux

Steps to reproduce this issue

provider config(spring xml)

 <dubbo:application name="dubbo-provider"  />
 <dubbo:registry protocol="zookeeper" file="registry.cache" address="127.0.0.1:2181" />
 <dubbo:protocol name="dubbo" port="2087" accesslog="true"/>
<dubbo:service interface="api.service.IRun" ref="runImpl" timeout="600000" cluster="failfast"/>

consumer config(spring xml)

<dubbo:application name="dubbo-consumer"  />
<dubbo:registry protocol="zookeeper" file="registry.cache" address="127.0.0.1:2181" />
<dubbo:protocol name="dubbo" port="2088" accesslog="true"/>
<dubbo:reference id="run" interface="api.service.IRun" connections="7"/>

What you expected to happen

After upgrading from Dubbo2 to Dubbo3.2.5, with the same configuration, the actual number of connections is twice normal, meaning that a consumer sends 14 connections to a provider.

Anything else

No response

Are you willing to submit a pull request to fix on your own?

  • Yes I am willing to submit a pull request on my own!

Code of Conduct

@lpcy lpcy added component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage labels Apr 25, 2024
@walkinggo
Copy link

i can see the number of connections in DubboProtocol#getClients and it's normal.can u provide more information?i can't reproduce this bug.

@lpcy
Copy link
Author

lpcy commented Apr 30, 2024

i can see the number of connections in DubboProtocol#getClients and it's normal.can u provide more information?i can't reproduce this bug.

I found that DubboProtocol#getClients will be called twice:
First:

getClients:419, DubboProtocol (org.apache.dubbo.rpc.protocol.dubbo)
protocolBindingRefer:412, DubboProtocol (org.apache.dubbo.rpc.protocol.dubbo)
......
toInvokers:430, RegistryDirectory (org.apache.dubbo.registry.integration)
refreshInvoker:292, RegistryDirectory (org.apache.dubbo.registry.integration)
refreshOverrideAndInvoker:233, RegistryDirectory (org.apache.dubbo.registry.integration)
notify:209, RegistryDirectory (org.apache.dubbo.registry.integration)
notify:533, AbstractRegistry (org.apache.dubbo.registry.support)
doNotify:373, FailbackRegistry (org.apache.dubbo.registry.support)
notify:365, FailbackRegistry (org.apache.dubbo.registry.support)
doSubscribe:241, ZookeeperRegistry (org.apache.dubbo.registry.zookeeper)
subscribe:300, FailbackRegistry (org.apache.dubbo.registry.support)
......
refreshInterfaceInvoker:464, MigrationInvoker (org.apache.dubbo.registry.client.migration)
migrateToApplicationFirstInvoker:245, MigrationInvoker (org.apache.dubbo.registry.client.migration)
refreshInvoker:76, MigrationRuleHandler (org.apache.dubbo.registry.client.migration)
doMigrate:60, MigrationRuleHandler (org.apache.dubbo.registry.client.migration)
......
createInvoker:615, ReferenceConfig (org.apache.dubbo.config)
createProxy:461, ReferenceConfig (org.apache.dubbo.config)
init:348, ReferenceConfig (org.apache.dubbo.config)
......

second:

getClients:419, DubboProtocol (org.apache.dubbo.rpc.protocol.dubbo)
protocolBindingRefer:412, DubboProtocol (org.apache.dubbo.rpc.protocol.dubbo)
......
toInvokers:419, ServiceDiscoveryRegistryDirectory (org.apache.dubbo.registry.client)
refreshInvoker:313, ServiceDiscoveryRegistryDirectory (org.apache.dubbo.registry.client)
refreshOverrideAndInvoker:197, ServiceDiscoveryRegistryDirectory (org.apache.dubbo.registry.client)
notify:189, ServiceDiscoveryRegistryDirectory (org.apache.dubbo.registry.client)
addListenerAndNotify:236, ServiceInstancesChangedListener (org.apache.dubbo.registry.client.event.listener)
subscribeURLs:330, ServiceDiscoveryRegistry (org.apache.dubbo.registry.client)
doSubscribe:227, ServiceDiscoveryRegistry (org.apache.dubbo.registry.client)
subscribe:189, ServiceDiscoveryRegistry (org.apache.dubbo.registry.client)
subscribe:88, ListenerRegistryWrapper (org.apache.dubbo.registry)
subscribe:184, DynamicDirectory (org.apache.dubbo.registry.integration)
subscribe:140, ServiceDiscoveryRegistryDirectory (org.apache.dubbo.registry.client)
doCreateInvoker:629, RegistryProtocol (org.apache.dubbo.registry.integration)
getServiceDiscoveryInvoker:65, InterfaceCompatibleRegistryProtocol (org.apache.dubbo.registry.integration)
refreshServiceDiscoveryInvoker:440, MigrationInvoker (org.apache.dubbo.registry.client.migration)
migrateToApplicationFirstInvoker:246, MigrationInvoker (org.apache.dubbo.registry.client.migration)
refreshInvoker:76, MigrationRuleHandler (org.apache.dubbo.registry.client.migration)
doMigrate:60, MigrationRuleHandler (org.apache.dubbo.registry.client.migration)
onRefer:249, MigrationRuleListener (org.apache.dubbo.registry.client.migration)
interceptInvoker:594, RegistryProtocol (org.apache.dubbo.registry.integration)
......
createInvoker:615, ReferenceConfig (org.apache.dubbo.config)
createProxy:461, ReferenceConfig (org.apache.dubbo.config)
init:348, ReferenceConfig (org.apache.dubbo.config)

The key method is MigrationInvoker#migrateToApplicationFirstInvoker. The getClients method will be called separately once:

    @Override
    public void migrateToApplicationFirstInvoker(MigrationRule newRule) {
        CountDownLatch latch = new CountDownLatch(0);
        refreshInterfaceInvoker(latch);
        refreshServiceDiscoveryInvoker(latch);

        // directly calculate preferred invoker, will not wait until address notify
        // calculation will re-occurred when address notify later
        calcPreferredInvoker(newRule);
    }

@walkinggo
Copy link

In version 3.x of Dubbo, to maintain compatibility with the older 2.x versions, Dubbo adopted a dual registration method during service migration, registering services both at the interface level and the application level. This is why the number of connections appears to be doubled.
you can see the explain in chinese version or english version .
You can find the details of the interface-level services in the ZooKeeper path /dubbo/com.example.ProductService/providers, and the details of the application-level services under the ZooKeeper path /dubbo/metadata/ProductApp.In ZooKeeper, you can indeed see that the specific number of connections is 7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage
Projects
Status: Todo
Development

No branches or pull requests

2 participants