现在,这适用于测试数据库,但在有数百万行的生产数据库中,它在获取 1,000 行后卡住并停止在屏幕上打印。我让它运行了一夜。
早上,我发送了QUIT信号并得到以下堆栈跟踪
SIGQUIT: quit
PC=0x5fecb m=0
goroutine 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 +0xb
runtime.semasleep1(0xffffffffffffffff, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/runtime/os1_darwin.go:385 +0xe5
runtime.semasleep.func1()
/usr/local/Cellar/go/1.5/libexec/src/runtime/os1_darwin.go:401 +0x29
runtime.systemstack(0x7fff5fbff100)
/usr/local/Cellar/go/1.5/libexec/src/runtime/asm_amd64.s:278 +0xab
runtime.semasleep(0xffffffffffffffff, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/runtime/os1_darwin.go:402 +0x36
runtime.notesleep(0x407970)
/usr/local/Cellar/go/1.5/libexec/src/runtime/lock_sema.go:169 +0x100
runtime.stopm()
/usr/local/Cellar/go/1.5/libexec/src/runtime/proc1.go:1128 +0x112
runtime.findrunnable(0xc82001d500, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/runtime/proc1.go:1530 +0x69e
runtime.schedule()
/usr/local/Cellar/go/1.5/libexec/src/runtime/proc1.go:1639 +0x267
runtime.park_m(0xc820000180)
/usr/local/Cellar/go/1.5/libexec/src/runtime/proc1.go:1698 +0x18b
runtime.mcall(0x7fff5fbff280)
/usr/local/Cellar/go/1.5/libexec/src/runtime/asm_amd64.s:204 +0x5b
问题:
为什么它在获取 1,000(appox) 行后立即卡住?
注释掉如何defer rows.Close()
立即停止卡住和恐慌?
有没有更好的方法来编写这个程序?
最后,如果以上这些是愚蠢的问题或问题太长,我很抱歉。我是 Go 的新手,正在努力学习。
一只萌萌小番薯
相关分类