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]偶发获取配置卡住 #90

Closed
qiluge opened this issue Dec 18, 2019 · 13 comments
Closed

[BUG]偶发获取配置卡住 #90

qiluge opened this issue Dec 18, 2019 · 13 comments
Assignees
Labels

Comments

@qiluge
Copy link
Contributor

qiluge commented Dec 18, 2019

agollo.GetConfig(namespace)一直卡住

如果是在重试从Apollo服务器获取配置,希望能加点log,至少让开发人员知道发生了啥。

@qiluge
Copy link
Contributor Author

qiluge commented Dec 18, 2019

这个是偶发的,我程序启动时会先读取Apollo读取配置,有些时候发现程序已启动就卡在那里不动了。我觉得可能是你那个apolloConfigCache锁住了,或者就是可能网络连不通一直在重试

@zouyx
Copy link
Member

zouyx commented Dec 18, 2019

你连的namespace有没有不存在的?有用自定义log来打日志么?

@qiluge
Copy link
Contributor Author

qiluge commented Dec 18, 2019

加了log之后打印了这个

[init notifySyncConfigServices finished]
[agollo start finished ! ]
[get all server info: [{"appName":"APOLLO-CONFIGSERVICE","instanceId":"A2-SP-CUSTODIAN-TEST-WAAS02:apollo-configservice:20080","homepageUrl":"http://xxxxxxxxx/"}]]
[syncServerIpList started]
[Config Not Modified: <nil>]
[Config Not Modified: <nil>]
[Config Not Modified: <nil>]

@qiluge
Copy link
Contributor Author

qiluge commented Dec 18, 2019

这个问题调试起来很蛋疼,用idea去debug跑每次都没问题,编译成可执行文件然后运行才会出现这个问题....

@zouyx
Copy link
Member

zouyx commented Dec 18, 2019

agollo.GetConfig(namespace)如果,这个一直卡住,有可能是2个问题造成

  • 对于不存在或没有发布过配置的namespace,如果去long polling的话,在apollo服务端是会hold住60秒的,因为对于long polling的场景,只要该namespace没有变化,就不会产生变化的通知,如果在long polling过程中该namespace发布了配置,那么该long polling会立马返回。

  • namespace从服务端获取信息失败,在重试。

我个人觉得是第一个问题居多,第一个问题我现在虽然做了异步,但是没设置超时所以可能会导致阻塞,你觉得像哪个问题,我模拟一下场景。

@qiluge
Copy link
Contributor Author

qiluge commented Dec 18, 2019

兄嘚,我调了半天,你看下https://github.com/zouyx/agollo/blob/master/repository.go#L112 为啥会锁住,这个wait要wait多久。
我加了两行log,发现只有wait start没有wait end,我在主线程里拿配置,然后整个主线程卡住了。
image

@zouyx
Copy link
Member

zouyx commented Dec 18, 2019

那就是第二个,namespace初始化没成功......https://github.com/zouyx/agollo/blob/22f6ac5189d6e3a071055d0ce7157254117d2a69/repository.go#L278

@qiluge
Copy link
Contributor Author

qiluge commented Dec 18, 2019

还有一种情况是你这里初始化完了,但是cache里面没有任何值:
image
image

@zouyx
Copy link
Member

zouyx commented Dec 18, 2019

@qiluge
Copy link
Contributor Author

qiluge commented Dec 18, 2019

https://github.com/zouyx/agollo/blob/22f6ac5189d6e3a071055d0ce7157254117d2a69/componet_notify.go#L91, 这里会修改全局变量allNotifications,函数initNamespaceNotifications不应该做这件事。
在repository里的GetConfigAndInit函数,创建完namespace的cache之后会修改allNotifications,导致后面一连串的问题。
具体说起来有点麻烦,我一会儿提个pull,里面是临时的修改办法。
我建议你把代码稍微重构一下,少用点全局变量,看得有点头疼。

@zouyx
Copy link
Member

zouyx commented Dec 18, 2019

谢谢建议,我尽量这周抽时间看看

@zouyx
Copy link
Member

zouyx commented Dec 21, 2019

Ref #91

@zouyx zouyx closed this as completed Dec 21, 2019
@zouyx
Copy link
Member

zouyx commented Dec 21, 2019

v2.2.6

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

No branches or pull requests

2 participants