Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: runtime error: index out of range [32] with length 9 [recovered] #1324

Closed
Linuxea opened this issue Apr 12, 2022 · 5 comments
Closed

Comments

@Linuxea
Copy link

Linuxea commented Apr 12, 2022

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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/callback_query.go:76 +0x42a
github.com/jinzhu/gorm.(*Scope).callCallbacks(0xc005cdd880, 0xc000213800, 0x3, 0x4, 0x0)
        /home/linuxea/go/pkg/mod/github.com/jinzhu/[email protected]/scope.go:869 +0x83
github.com/jinzhu/gorm.(*DB).Scan(0xc0031bb860, 0x127b820, 0xc005416f88, 0xc00643dd50)
        /home/linuxea/go/pkg/mod/github.com/jinzhu/[email protected]/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

image

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 version:
image

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

@Linuxea
Copy link
Author

Linuxea commented Apr 12, 2022

I found a very similar issue runtime error: slice bounds out of range in packets.go #587

But my go-sql-driver version is v1.6.0. The bug had been fixed after v1.4.0.

@methane
Copy link
Member

methane commented Apr 13, 2022

5.7.17 is too old. Can you reproduce it with latest version? (e.g. 5.7.37, or 8.0.28)

@Linuxea
Copy link
Author

Linuxea commented Apr 13, 2022

I can't reproduce it with version
image

@methane
Copy link
Member

methane commented Apr 14, 2022

Then, may I close this issue?

@Linuxea
Copy link
Author

Linuxea commented Apr 14, 2022

Maybe no. I could update in some days later.

@Linuxea Linuxea closed this as completed Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants