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

Start()后会把所有的数据置为空 #39

Closed
zlyuancn opened this issue Jun 13, 2020 · 3 comments
Closed

Start()后会把所有的数据置为空 #39

zlyuancn opened this issue Jun 13, 2020 · 3 comments

Comments

@zlyuancn
Copy link

zlyuancn commented Jun 13, 2020

    c, err := agollo.New("http://127.0.0.1:8080", "test",
        agollo.AutoFetchOnCacheMiss(),
        //  agollo.FailTolerantOnBackupExists(),  // 关闭容灾
    )
    failOnError(err, "初始化失败")
    defer c.Stop()

    _ = c.Start()

    func() {
        for {
            time.Sleep(1e9)
            fmt.Println("a:", c.Get("a"), "b:", c.Get("b"))
        }
    }()

结果如下:
a: 1 b: 2
a: b:
a: b:
a: b:
a: b:
a: b:
...

@zlyuancn
Copy link
Author

我调试了你的代码, 我认为问题出在 agollo.go 文件的166行, 收到的status为304, 所以你将空结果覆盖了正常的结果. 当然如果开启了容灾(174行), 这个程序不会出问题.

上测: 在 reloadNamespace() 方法中将旧的 NotificationID 传入, 方法内检查旧的 NotificationID 为-1时使用不同策略
中策: 可以考虑在(477行)加入判断, 当旧的 NotificationID 为-1时, 不需要加载新的值
下策: 我还是开启 agollo.FailTolerantOnBackupExists()

@shima-park
Copy link
Owner

非常感谢你的反馈,我修复一下这个问题。

@shima-park
Copy link
Owner

shima-park commented Jun 13, 2020

@zlyuancn 我已在最新的release版本中修复该问题release
再次感谢你的支持和反馈.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants