nacos icon indicating copy to clipboard operation
nacos copied to clipboard

[Bug]:Can not aquire the specific config

Open robocanic opened this issue 1 year ago • 9 comments

Describe the bug

environments:

  • java version: corretto 21
  • nacos sdk/client version: 2.3.2
  • nacos deployment mode: standalone, windows10 PC

I start a dubbo service on local PC(the code of this dubbo service comes from the dubbo-samples), using nacos client 2.2.0. And it works fine, the service registered and I can find the config and service info through the console: image image

Following the "quick start" of the official website , I want to get the config content of "dataId=org.apache.dubbo.samples.UserService:::provider:shop-user, group=dubbo" as below:

public class NacosApplication {
    public static void main(String[] args) {
        String content;
        try {
            String serverAddr = "localhost:8848";
            String dataId = "org.apache.dubbo.samples.UserService:::provider:shop-user";
            String group = "dubbo";
            Properties properties = new Properties();
            properties.put("serverAddr", serverAddr);
            ConfigService configService = NacosFactory.createConfigService(properties);
            content = configService.getConfig(dataId, group, 5000);
            System.out.println("content is:"+content);
        } catch (NacosException e) {
            e.printStackTrace();
        }
    }
}

The expected result config content should be : image But it returns null: image

Then I change the dataId and group to try to aquire another config content:

public class NacosApplication {
    public static void main(String[] args) {
        String content;
        try {
            String serverAddr = "localhost:8848";
            String dataId = "org.apache.dubbo.samples.UserService";
            String group = "mapping";
            Properties properties = new Properties();
            properties.put("serverAddr", serverAddr);
            ConfigService configService = NacosFactory.createConfigService(properties);
            content = configService.getConfig(dataId, group, 5000);
            System.out.println("content is:"+content);
        } catch (NacosException e) {
            e.printStackTrace();
        }
    }
}

It works fine just as below, which is really wired: image image

I have confirmed that the dataId and group is the same as the console shows, I have no idea for this bug, can someone tell me where the problem lies?

robocanic avatar Apr 16 '24 02:04 robocanic

你好,麻烦将不可用的配置内容,dataId和group发一下,我复现下看看

985492783 avatar Apr 16 '24 05:04 985492783

你好,麻烦将不可用的配置内容,dataId和group发一下,我复现下看看

dataId: org.apache.dubbo.samples.UserService:::provider:shop-user group: dubbo content: {"annotations":[],"canonicalName":"org.apache.dubbo.samples.UserService","codeSource":"file:/D:/code/dubbo-samples/10-task/dubbo-samples-shop/dubbo-samples-shop-user-api/target/classes/","methods":[{"annotations":[],"name":"register","parameterTypes":["org.apache.dubbo.samples.User"],"parameters":[],"returnType":"boolean"},{"annotations":[],"name":"getInfo","parameterTypes":["java.lang.String"],"parameters":[],"returnType":"org.apache.dubbo.samples.User"},{"annotations":[],"name":"login","parameterTypes":["java.lang.String","java.lang.String"],"parameters":[],"returnType":"org.apache.dubbo.samples.User"},{"annotations":[],"name":"timeoutLogin","parameterTypes":["java.lang.String","java.lang.String"],"parameters":[],"returnType":"org.apache.dubbo.samples.User"}],"parameters":{"anyhost":"true","pid":"20560","interface":"org.apache.dubbo.samples.UserService","side":"provider","dubbo":"2.0.2","application":"shop-user","release":"3.2.7","executor-management-mode":"isolation","file-cache":"true","methods":"getInfo,login,register,timeoutLogin","deprecated":"false","qos.port":"20994","service-name-mapping":"true","timeout":"1000","generic":"false","bind.port":"20884","token":"d9f0fc3f-2fc6-4684-9405-e8c2311df916","qos.anonymous.access.permission.level":"PROTECTED","bind.ip":"2.0.0.1","prefer.serialization":"fastjson2,hessian2","background":"false","dynamic":"true","qos.anonymous.access.allow.commands":"metrics","timestamp":"1713234842852"},"types":[{"enums":[],"items":[],"properties":{},"type":"boolean"},{"enums":[],"items":[],"properties":{"realName":"java.lang.String","password":"java.lang.String","mail":"java.lang.String","phone":"java.lang.String","env":"java.lang.String","username":"java.lang.String"},"type":"org.apache.dubbo.samples.User"},{"enums":[],"items":[],"properties":{},"type":"java.lang.String"}],"uniqueId":"org.apache.dubbo.samples.UserService@file:/D:/code/dubbo-samples/10-task/dubbo-samples-shop/dubbo-samples-shop-user-api/target/classes/"}

robocanic avatar Apr 16 '24 05:04 robocanic

我用jdk8和jdk21都没有复现出来,客户端debug看下请求 服务端看下config-pull-check.log,或者配置nacos.plugin.datasource.log.enabled=true看下sql对不对

985492783 avatar Apr 16 '24 06:04 985492783

debug: image-20240416172752667

config-dump.log

image-20240416173742502

config-pull-check.log

image-20240416173834122

看起来是server端有些问题

robocanic avatar Apr 16 '24 09:04 robocanic

看样子是client获取到数据后保存快照的时候报错了,文件名特殊符号不支持

985492783 avatar Apr 16 '24 10:04 985492783

新版本应该在写缓存的时候有进行encode的,是否是系统版本读取的时候没读取正确?

可以看下 PathEncode 和PathEncodeManager是否没有用上或者读取错误导致没有识别到用Windows的PathEncode

KomachiSion avatar Apr 17 '24 02:04 KomachiSion

#10101

KomachiSion avatar Apr 17 '24 02:04 KomachiSion

com.alibaba.nacos.config.server.service.dump.disk.ConfigRawDiskService

DiskUtil被迁移到了这个上面,但是丢失了#10101中的encode修复

KomachiSion avatar Apr 17 '24 02:04 KomachiSion

这个问题在哪些版本中存在?

robocanic avatar Apr 22 '24 08:04 robocanic