golangでpostgresqlを使用してrows.next()を使用して行を仲裁するときにエラーが発生します。これは、いくつかのマシンで非常に予期しないタイミングで発生し、デバッグが困難になります。パニック上記の呼び出しスタックからGolang、postgresql rows.next()パニック
panic: runtime error: index out of range [recovered]
panic: runtime error: index out of range
goroutine 28078 [running]:
panic(0xa63ae0, 0xc420014090)
/usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/lib/pq.(*conn).errRecover(0xc420780500, 0xc420d2ef28)
/share/dpkg-build/pacman-build/src/github.com/lib/pq/error.go:482 +0x57e
panic(0xa63ae0, 0xc420014090)
/usr/local/go/src/runtime/panic.go:458 +0x243
github.com/lib/pq.binaryDecode(0xc420780728, 0xc4207806f0, 0x0, 0x30, 0xc400000017, 0xa24300, 0xc421fcb4b0)
/share/dpkg-build/pacman-build/src/github.com/lib/pq/encode.go:76 +0x385
github.com/lib/pq.decode(0xc420780728, 0xc4207806f0, 0x0, 0x30, 0x17, 0x1, 0xa24300, 0xc421fcb4b0)
/share/dpkg-build/pacman-build/src/github.com/lib/pq/encode.go:61 +0x6c
github.com/lib/pq.(*rows).Next(0xc42281e310, 0xc420b82000, 0x2f, 0x2f, 0x0, 0x0)
/share/dpkg-build/pacman-build/src/github.com/lib/pq/conn.go:1369 +0x420
database/sql.(*Rows).Next(0xc42005b560, 0xc4204eb590)
/usr/local/go/src/database/sql/sql.go:1758 +0x6c
github.com/xxxxx/yyyyy/src/product/elasticsearch.getPart1(0xc4204eb590, 0xa24300, 0xc420a04190, 0x0, 0x0) <-- rows.next() here
/share/dpkg-build/pacman-build/src/github.com/xxxxxx/yyyyyy/src/product/elasticsearch/collector.go:71 +0xff
github.com/xxxxx/yyyyy/src/product/elasticsearch.Get(0xa24300, 0xc420a04190, 0xc420a04190, 0xa24300, 0xc420a04190, 0xc420980a00)
/share/dpkg-build/pacman-build/src/github.com/xxxxxx/yyyyyy/src/product/elasticsearch/collector.go:29 +0x118
は、私はそれだけでいくつかのマシンで起こっている理由を説明想像binaryDecode機能から来ています。悪質なネットワークパッケージがあるか、またはメッセージが破損している可能性があります。そのため、ドライバはメッセージをデコードして失敗する可能性があります。
しかし、私はこの後にどこに行くのか分からない、誰もがアイデアを持っていますか?
おかげ
あなたはレース検出器と、このコードをテストしていますか?これは、一見無作為な、または予期しないバグで最初にやるべきことです。 – JimB
まだありません、 は私にとってこの良い出発点です[Data Race Detector](https://golang.org/doc/articles/race_detector.html)? または別の提案がありますか? –
私は準備された声明を使用しています。競合状態であればそこから来ている可能性があります。 –