现在,这适用于测试数据库,但在有数百万行的生产数据库中,它在获取 1,000 行后卡住并停止在屏幕上打印。我让它运行了一夜。早上,我发送了QUIT信号并得到以下堆栈跟踪SIGQUIT: quitPC=0x5fecb m=0goroutine 0 [idle]:runtime.mach_semaphore_wait(0xe03, 0x0, 0x0, 0x0, 0x0, 0x407520, 0x52db9, 0xffffffffffffffff, 0x0, 0x7fff5fbff0fc, ...) /usr/local/Cellar/go/1.5/libexec/src/runtime/sys_darwin_amd64.s:407 +0xbruntime.semasleep1(0xffffffffffffffff, 0x0) /usr/local/Cellar/go/1.5/libexec/src/runtime/os1_darwin.go:385 +0xe5runtime.semasleep.func1() /usr/local/Cellar/go/1.5/libexec/src/runtime/os1_darwin.go:401 +0x29runtime.systemstack(0x7fff5fbff100) /usr/local/Cellar/go/1.5/libexec/src/runtime/asm_amd64.s:278 +0xabruntime.semasleep(0xffffffffffffffff, 0x0) /usr/local/Cellar/go/1.5/libexec/src/runtime/os1_darwin.go:402 +0x36runtime.notesleep(0x407970) /usr/local/Cellar/go/1.5/libexec/src/runtime/lock_sema.go:169 +0x100runtime.stopm() /usr/local/Cellar/go/1.5/libexec/src/runtime/proc1.go:1128 +0x112runtime.findrunnable(0xc82001d500, 0x0) /usr/local/Cellar/go/1.5/libexec/src/runtime/proc1.go:1530 +0x69eruntime.schedule() /usr/local/Cellar/go/1.5/libexec/src/runtime/proc1.go:1639 +0x267runtime.park_m(0xc820000180) /usr/local/Cellar/go/1.5/libexec/src/runtime/proc1.go:1698 +0x18bruntime.mcall(0x7fff5fbff280) /usr/local/Cellar/go/1.5/libexec/src/runtime/asm_amd64.s:204 +0x5b问题:为什么它在获取 1,000(appox) 行后立即卡住?注释掉如何defer rows.Close()立即停止卡住和恐慌?有没有更好的方法来编写这个程序?最后,如果以上这些是愚蠢的问题或问题太长,我很抱歉。我是 Go 的新手,正在努力学习。
- 1 回答
- 0 关注
- 288 浏览
添加回答
举报
0/150
提交
取消