GO服务 所有协程无法服务。

woaichimian · 2017-02-15 06:41:21 · 6106 次点击 · 大约8小时之前 开始浏览    置顶
这是一个创建于 2017-02-15 06:41:21 的主题,其中的信息可能已经有所发展或是发生改变。

自己写的GO服务在跑了几天后会出现所有携程无法服务, 表现在业务携程TCP建立后无法接收TCP recv_q的数据,处理信号的协成无法处理信号,pprof端口在的进程也无法响应。TCP 接受队列堆积 屏幕快照 2017-02-15 下午2.40.30.png 但是 进程还显示100%左右的CPU的占用, 有什么方法进行定位么?


有疑问加站长微信联系(非本文作者)

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

6106 次点击  
加入收藏 微博
11 回复  |  直到 2020-08-05 09:12:56
blov
blov · #1 · 8年之前

服务停掉,再启动,过段时间还会这样?试试 strace,也可以用 gops 试试

woaichimian
woaichimian · #2 · 8年之前
blovblov #1 回复

服务停掉,再启动,过段时间还会这样?试试 strace,也可以用 [gops](https://github.com/google/gops) 试试

现在的感觉是在调度器部分死锁了 gdb进去调试

(gdb) bt
#0  runtime.futex () at /home/xuegeng/go/src/runtime/sys_linux_amd64.s:307
#1  0x000000000042c4e0 in runtime.futexsleep (addr=0x11d3020 , val=0, ns=100000) at /home/xuegeng/go/src/runtime/os1_linux.go:57
#2  0x000000000041103b in runtime.notetsleep_internal (n=0x11d3020 , ns=100000, ~r2=false) at /home/xuegeng/go/src/runtime/lock_futex.go:174
#3  0x000000000041112b in runtime.notetsleep (n=0x11d3020 , ns=100000, ~r2=false) at /home/xuegeng/go/src/runtime/lock_futex.go:194
#4  0x00000000004334ad in runtime.stopTheWorldWithSema () at /home/xuegeng/go/src/runtime/proc.go:963
#5  0x000000000045f419 in runtime.systemstack () at /home/xuegeng/go/src/runtime/asm_amd64.s:291
#6  0x0000000000433870 in runtime.startTheWorldWithSema () at /home/xuegeng/go/src/runtime/proc.go:986
#7  0x000000c82001a000 in ?? ()
#8  0x0000000000000000 in ?? ()

然后strace 时 显示这样 目前GO 版本是1.6 ,debian

[pid 231942] futex(0x11d3020, FUTEX_WAIT, 0, {0, 100000}) = -1 ETIMEDOUT (Connection timed out)
[pid 231942] futex(0x11d3020, FUTEX_WAIT, 0, {0, 100000}) = -1 ETIMEDOUT (Connection timed out)
[pid 231942] futex(0x11d3020, FUTEX_WAIT, 0, {0, 100000}) = -1 ETIMEDOUT (Connection timed out)
[pid 231942] futex(0x11d3020, FUTEX_WAIT, 0, {0, 100000}) = -1 ETIMEDOUT (Connection timed out)
[pid 231942] futex(0x11d3020, FUTEX_WAIT, 0, {0, 100000}) = -1 ETIMEDOUT (Connection timed out)
[pid 231942] futex(0x11d3020, FUTEX_WAIT, 0, {0, 100000}) = -1 ETIMEDOUT (Connection timed out)
[pid 231942] futex(0x11d3020, FUTEX_WAIT, 0, {0, 100000}) = -1 ETIMEDOUT (Connection timed out)
[pid 231942] futex(0x11d3020, FUTEX_WAIT, 0, {0, 100000}) = -1 ETIMEDOUT (Connection timed out)
[pid 231942] futex(0x11d3020, FUTEX_WAIT, 0, {0, 100000}) = -1 ETIMEDOUT (Connection timed out)
[pid 231942] futex(0x11d3020, FUTEX_WAIT, 0, {0, 100000}) = -1 ETIMEDOUT (Connection timed out)
[pid 231942] futex(0x11d3020, FUTEX_WAIT, 0, {0, 100000}) = -1 ETIMEDOUT (Connection timed out)
[pid 231942] futex(0x11d3020, FUTEX_WAIT, 0, {0, 100000}) = -1 ETIMEDOUT (Connection timed out)

我试试gops ,感觉是不行的。。

muzixiaoxin
muzixiaoxin · #3 · 8年之前

有可能是死循环了,查一下所有的for

jielaming
jielaming · #4 · 8年之前

看看你的 协程里面用到的管道 可能是你的管道卡住了 ===

woaichimian
woaichimian · #5 · 8年之前
jielamingjielaming #4 回复

看看你的 协程里面用到的管道 可能是你的管道卡住了 ===

单一的管道卡主,不会造成所有的协成无法调度 ,看到官方ISSUE里面有提到,目前升级版本没有复现问题。

woaichimian
woaichimian · #6 · 8年之前
muzixiaoxinmuzixiaoxin #3 回复

有可能是死循环了,查一下所有的for

看到官方ISSUE,有类似的问题,目前升级版本解决》。。。

jielaming
jielaming · #7 · 8年之前
woaichimianwoaichimian #6 回复

#3楼 @muzixiaoxin 看到官方ISSUE,有类似的问题,目前升级版本解决》。。。

能否发代码上来看看

woaichimian
woaichimian · #8 · 8年之前
jielamingjielaming #7 回复

#6楼 @woaichimian 能否发代码上来看看

https://github.com/xuewindy/dbatman 这个不过不太好看,是个mysql proxy,出问题的环境有几十个库再跑,不知道怎么飞到那里去的 ,有兴趣可以看看。。

lys861205
lys861205 · #9 · 8年之前

被动关闭一方会处于close_wait状态, 没有调用close函数,导致大量的close_wait!

supersnailaixiang
supersnailaixiang · #10 · 5年之前

后续这个解决了吗?

wuchenghui
wuchenghui · #11 · 5年之前

数据量太大了吧,处理不过来了

添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传