mysql: runtime error: slice bounds out of range in packets.go
Issue description
When using many concurrent SQL queries (same pool), I get a slice out of bounds error.
The corresponding logic in jmoiron/sqlx seems fine. It’s just a call to (*Rows).Next() which is causing this.
Similar to #36 perhaps?
Error log
panic: runtime error: slice bounds out of range
goroutine 4814 [running]:
mypackage/vendor/github.com/go-sql-driver/mysql.(*binaryRows).readRow(0xc4205a2160, 0xc422be3140, 0xc, 0xc, 0xc, 0xc422be3080)
/home/gm42/projects/mypackage/src/mypackage/vendor/github.com/go-sql-driver/mysql/packets.go:1168 +0x92d
mypackage/vendor/github.com/go-sql-driver/mysql.(*binaryRows).Next(0xc4205a2160, 0xc422be3140, 0xc, 0xc, 0xc, 0xc)
/home/gm42/projects/mypackage/src/mypackage/vendor/github.com/go-sql-driver/mysql/rows.go:85 +0x5e
database/sql.(*Rows).nextLocked(0xc422b6da80, 0xc4206ac4b0)
/usr/local/go/src/database/sql/sql.go:2149 +0x6c
database/sql.(*Rows).Next.func1()
/usr/local/go/src/database/sql/sql.go:2134 +0x3c
database/sql.withLock(0xeb1640, 0xc422b6dab0, 0xc4206ac4f0)
/usr/local/go/src/database/sql/sql.go:2545 +0x65
database/sql.(*Rows).Next(0xc422b6da80, 0xb82ce0)
/usr/local/go/src/database/sql/sql.go:2135 +0x83
mypackage/vendor/github.com/jmoiron/sqlx.(*Row).Scan(0xc4223b0870, 0xc422be2fc0, 0xc, 0xc, 0x0, 0x0)
Configuration
Driver version (or git SHA): 1421caf44f6464fd2ee8de694c7508ee13f92964
Go version: go version go1.8.1 linux/amd64
Server version: MySQL 5.6.27
Server OS: Ubuntu 16
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 21 (10 by maintainers)
Commits related to this issue
- remove columns definition cache. fixes #587 — committed to methane/mysql by methane 7 years ago
- remove columns definition cache. fixes #587 — committed to methane/mysql by methane 7 years ago
- remove columns definition cache. (#592) fixes #587 — committed to go-sql-driver/mysql by methane 7 years ago
OK. There are no guarantee that same statement returns same column definition every time.
So we should check column definition packet are exactly same bytes before reusing parsed column definition. Or we can just remove column definition cache.