apache / dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.
https://dubbo.apache.org/
Apache License 2.0
40.5k stars 26.43k forks source link

dubbo 3.0.0 + spring boot + nacos always add one config on bootstrap #8096

Closed EarthChen closed 3 years ago

EarthChen commented 3 years ago

Environment

Steps to reproduce this issue

build.gradle

compile('com.alibaba.nacos:nacos-client:2.0.2')
implementation("org.apache.dubbo:dubbo-spring-boot-starter:3.0.0")
implementation("org.apache.dubbo:dubbo-registry-nacos:3.0.0")

application.yaml

dubbo:
  scan:
    base-packages: com.test.dubbo.impl
  registry:
    address: nacos://127.0.0.1:8848?username=nacos&password=nacos&namespace=test
    username: nacos
    password: nacos
    group: test
    parameters:
      group: test
      namespace: test
      username: nacos
      password: nacos
  protocol:
    port: 20880

image

Always add one when you reboot..

but dubbo:2.7.12 will not happen and config list less


And I found out why is that.

MetadataInfo.java

public String calAndGetRevision() {
        if (revision != null && hasReported()) {
            return revision;
        }

        if (CollectionUtils.isEmptyMap(services)) {
            this.revision = RevisionResolver.getEmptyRevision(app);
        } else {
            StringBuilder sb = new StringBuilder();
            sb.append(app);
            for (Map.Entry<String, ServiceInfo> entry : new TreeMap<>(services).entrySet()) {
                sb.append(entry.getValue().toDescString());
            }
            this.revision = RevisionResolver.calRevision(sb.toString());
        }
        return revision;
    }
  • services have a field pid and timestamp, it will be different every time. so when cal revision ,the value is different
  • It will not affect, but it will result in a lot of useless configuration
    
    // eg: sb.toString()
    // 1
    test-dubbo-providercom.test.dubbo.IHelloService:dubbo[public abstract java.lang.String com.test.dubbo.IHelloService.hello()]{anyhost=true, application=test-dubbo-provider, deprecated=false, dubbo=2.0.2, dynamic=true, generic=false, interface=com.test.dubbo.IHelloService, metadata-type=remote, methods=hello, pid=87871, release=3.0.0, side=provider, timestamp=1624243176253}

//2 test-dubbo-providercom.test.dubbo.IHelloService:dubbo[public abstract java.lang.String com.test.dubbo.IHelloService.hello()]{anyhost=true, application=test-dubbo-provider, deprecated=false, dubbo=2.0.2, dynamic=true, generic=false, interface=com.test.dubbo.IHelloService, metadata-type=remote, methods=hello, pid=87977, release=3.0.0, side=provider, timestamp=1624243377597}

CrazyHZM commented 3 years ago

The question to be considered here is whether pid and timestamp should be used as the only revision of metadata.

EarthChen commented 3 years ago

Yes, this can create a lot of useless data for metadata centers, especially for frequently scheduled environments like k8s

CrazyHZM commented 3 years ago

Has been resolved in the new version.