go-sql-driver / mysql

Go MySQL Driver is a MySQL driver for Go's (golang) database/sql package
https://pkg.go.dev/github.com/go-sql-driver/mysql
Mozilla Public License 2.0
14.42k stars 2.31k forks source link

when the connect is more than 900,it will panic #1607

Closed zutim closed 1 month ago

zutim commented 1 month ago

panic: runtime error: index out of range [3] with length 3

goroutine 1575 [running]: github.com/go-sql-driver/mysql.(mysqlConn).handleErrorPacket(0xc000eaaf00?, {0xc0025a0004, 0x3, 0xffc}) /root/go/pkg/mod/github.com/go-sql-driver/mysql@v1.8.1/packets.go:585 +0x193 github.com/go-sql-driver/mysql.(mysqlConn).readHandshakePacket(0xc000eaaf00) /root/go/pkg/mod/github.com/go-sql-driver/mysql@v1.8.1/packets.go:171 +0x54d github.com/go-sql-driver/mysql.(connector).Connect(0xc00000f248, {0xc20720, 0xc00002a1d0}) /root/go/pkg/mod/github.com/go-sql-driver/mysql@v1.8.1/connector.go:132 +0x6c5 database/sql.(DB).conn(0xc000217450, {0xc20720, 0xc00002a1d0}, 0x1) /usr/local/go/src/database/sql/sql.go:1395 +0x782 database/sql.(DB).query(0x0?, {0xc20720, 0xc00002a1d0}, {0xc0004a7ea0, 0x4c}, {0xc000eff680, 0x1, 0x8}, 0x0?) /usr/local/go/src/database/sql/sql.go:1732 +0x5d database/sql.(DB).QueryContext(0xc0006f3680?, {0xc20720, 0xc00002a1d0}, {0xc0004a7ea0, 0x4c}, {0xc000eff680, 0x1, 0x8}) /usr/local/go/src/database/sql/sql.go:1710 +0xda gorm.io/gorm/callbacks.Query(0xc0006f3680) /root/go/pkg/mod/gorm.io/gorm@v1.25.1/callbacks/query.go:20 +0xb2 gorm.io/gorm.(processor).Execute(0xc00021eaf0, 0xabb0c0?) /root/go/pkg/mod/gorm.io/gorm@v1.25.1/callbacks.go:130 +0x3af gorm.io/gorm.(DB).First(0x0?, {0xa32920?, 0xc000eff700}, {0x0, 0x0, 0x0}) /root/go/pkg/mod/gorm.io/gorm@v1.25.1/finisher_api.go:131 +0x1bc

myconfig is maxIdle: 1000 maxOpen: 1200 maxLife: 2000

zutim commented 1 month ago

I see the mysql max_connections is 1024, so I think tcp refused connections. we can deal the panic

methane commented 1 month ago

Why do you ignore the issue template? It includes very important informations like server version. Reporting incomplete issue by ignoring template is no good manner.