Closed
Description
background
Our team changed to another cloud MySQL business recently.
issue description
Sometimes I get panic information When I query the database and sometimes not.
Example code
func (*gameAccountManagerDao) UnLockGameAccountBatchStock(tx *gorm.DB, id int64) error {
batch := &model.GameAccountBatchManager{}
sql := "select * from game_account_batch_manager where id = ? for update"
err := tx.Raw(sql, id).Scan(&batch).Error
if err != nil {
return err
}
return nil
}
Error log
[2022-04-12 15:13:51] [0.69ms] select * from game_account_batch_manager where id = 92 for update
[0 rows affected or returned ]
panic: runtime error: index out of range [32] with length 9 [recovered]
panic: runtime error: index out of range [32] with length 9
goroutine 60995 [running]:
github.com/jinzhu/gorm.(*Scope).callCallbacks.func1(0xc005cdd880)
/home/linuxea/go/pkg/mod/github.com/jinzhu/gorm@v1.9.16/scope.go:865 +0xba
panic(0x165fbc0, 0xc002cfe6f0)
/home/linuxea/soft/go/src/runtime/panic.go:965 +0x1b9
github.com/go-sql-driver/mysql.(*binaryRows).readRow(0xc0001a6e10, 0xc003a4d680, 0xf, 0xf, 0xc000052001, 0xc003a4d680)
/home/linuxea/go/pkg/mod/github.com/go-sql-driver/mysql@v1.6.0/packets.go:1220 +0x1510
github.com/go-sql-driver/mysql.(*binaryRows).Next(0xc0001a6e10, 0xc003a4d680, 0xf, 0xf, 0xc003a4d590, 0xc0075289d8)
/home/linuxea/go/pkg/mod/github.com/go-sql-driver/mysql@v1.6.0/rows.go:198 +0x89
database/sql.(*Rows).nextLocked(0xc005cdd900, 0xc0022f0000)
/home/linuxea/soft/go/src/database/sql/sql.go:2865 +0xbf
database/sql.(*Rows).Next.func1()
/home/linuxea/soft/go/src/database/sql/sql.go:2843 +0x3c
database/sql.withLock(0x18f3b88, 0xc005cdd930, 0xc007528a30)
/home/linuxea/soft/go/src/database/sql/sql.go:3294 +0x69
database/sql.(*Rows).Next(0xc005cdd900, 0xc003a4d590)
/home/linuxea/soft/go/src/database/sql/sql.go:2842 +0x87
github.com/jinzhu/gorm.queryCallback(0xc005cdd880)
/home/linuxea/go/pkg/mod/github.com/jinzhu/gorm@v1.9.16/callback_query.go:76 +0x42a
github.com/jinzhu/gorm.(*Scope).callCallbacks(0xc005cdd880, 0xc000213800, 0x3, 0x4, 0x0)
/home/linuxea/go/pkg/mod/github.com/jinzhu/gorm@v1.9.16/scope.go:869 +0x83
github.com/jinzhu/gorm.(*DB).Scan(0xc0031bb860, 0x127b820, 0xc005416f88, 0xc00643dd50)
/home/linuxea/go/pkg/mod/github.com/jinzhu/gorm@v1.9.16/main.go:364 +0xe5
niubigit.caijiyouxi.com/yungame/server/src/yunGame/store/dao.(*gameAccountManagerDao).UnLockGameAccountBatchStock(0x255ece0, 0xc0031bb2b0, 0x5c, 0xc002d9c260, 0x1)
/home/linuxea/Desktop/code/caiji/server/src/yunGame/store/dao/game_account_manager_dao.go:281 +0x136
Configuration
Driver version (or git SHA): github.com/go-sql-driver/mysql v1.6.0
Go version: go version go1.16.4 linux/amd64
Server OS: Linux VM-0-46-centos 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
gorm version: github.com/jinzhu/gorm v1.9.16
Metadata
Metadata
Assignees
Labels
No labels