apolloconfig / agollo

🚀Go client for ctrip/apollo (https://github.com/apolloconfig/apollo)
https://www.apolloconfig.com
Apache License 2.0
708 stars 189 forks source link

[BUG]当阿波罗命名空间的配置文件为空时 阿波罗去获取数据库的时候会导致进入等待状态卡死进程 #273

Closed a67793581 closed 1 year ago

a67793581 commented 1 year ago

请简单描述bug的场景 当阿波罗命名空间的配置文件为空时 阿波罗去获取数据库的时候会导致进入等待状态卡死进程 如何重现

    fmt.Println("阿波罗建立连接")
    fmt.Println("xxx", ApolloClient.GetConfig("application").GetValue("xxx"))
//getConfigValue 获取配置值
func (c *Config) getConfigValue(key string) interface{} {
    fmt.Println("获取配置值")
    b := c.GetIsInit()
    if !b {
        fmt.Println("进入等待状态")
        c.waitInit.Wait()
    }
    if c.cache == nil {
        log.Errorf("get config value fail!namespace:%s is not exist!", c.namespace)
        return nil
    }

    value, err := c.cache.Get(key)
    if err != nil {
        log.Errorf("get config value fail!key:%s,err:%s", key, err)
        return nil
    }

    return value
}

再现行为的步骤:

1.设置一个空的阿波罗命名空间 2.使用该客户端连接到这个配置 并读取命名空间下的值 3.进入等待状态卡死进程 期望 请描述期望发生什么 当命名空间为空的时候获取某一个值应该直接返回或者报错 或者提供日志 以及注释说明 截图 image

Agollo 版本 :

日志信息

其他上下文 日志 {"level":"INFO","time":"2023-04-04 12:00:35.856003","caller":"E:/code/hj/live/micro-services/user_behavior_analysis_system/vendor/github.com/apolloconfig/agollo/v4/component/log/log.go:78","func":"github.com/apolloconfig/agollo/v4/component/log.Info","message":"agollo_sdk_log","msg":[["agollo start finished ! "]]} 阿波罗建立连接 获取配置值 进入等待状态

yiwenqi commented 1 year ago

How about this bug? had fix?

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.