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: When the service kv does not exist, the fetch timer of consul_kv will fetch service data frantically, resulting in 100% CPU #4632

Closed
forcemain opened this issue Jul 20, 2021 · 7 comments · Fixed by #4979
Assignees
Labels
bug Something isn't working

Comments

@forcemain
Copy link

当服务kv不存在时consul_kv的fetch timer会疯狂获取服务数据导致CPU 100%

2021/07/20 07:11:55 [error] 42#42: *193170 [lua] consul_kv.lua:329: connect consul: http://10.242.154.205:8500/v1/kv/ by key: /kv/apisix-service-upstreams, got result: null, with error: timeout, context: ngx.timer

目测是因为_M.connect异常后直接再次跳转到:: ERR ::再次尝试_M.connect~ 死循环了

@spacewander spacewander added the bug Something isn't working label Jul 20, 2021
@spacewander
Copy link
Member

What about using exponential backoff with retry instead of retrying immediately?
We can try after 1,4,16,64,256,256,... seconds.

@yongboy
Copy link
Contributor

yongboy commented Jul 20, 2021

This is a bug now :))
I would submit a PR later to fix it.

And, if you want to avoid the bug at the moment, you should insert some test data into /apisix-service-upstreams key space.

@forcemain
Copy link
Author

@yongboy yeah, i see

@forcemain
Copy link
Author

@sbritocorral yeah, periodic increase maybe better

@tokers
Copy link
Contributor

tokers commented Jul 20, 2021

Agree, currently, the next timer will be created at once.

@moonming moonming changed the title bug: 当服务kv不存在时consul_kv的fetch timer会疯狂获取服务数据导致CPU 100% bug: When the service kv does not exist, the fetch timer of consul_kv will fetch service data frantically, resulting in 100% CPU Jul 22, 2021
@Zheaoli
Copy link
Member

Zheaoli commented Sep 3, 2021

@yongboy Is there anything update?

@spacewander
Copy link
Member

@Zheaoli
I am working on it.

@spacewander spacewander self-assigned this Sep 3, 2021
spacewander added a commit to spacewander/incubator-apisix that referenced this issue Sep 3, 2021
Fix apache#4632
Signed-off-by: spacewander <spacewanderlzx@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants