-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Panic when a closed connnection is used #142
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
Comments
Stmt.Exec() have problem, db.Exec() is OK |
It looks like #98 - we can't do much about that, it's a problem in go's database/sql. They don't accept a fix until go version 1.2 is released. |
At least the panic in the driver code shouldn't happen. |
We found the cause. |
go 1.2rc2 test fail, it does not seem to fix. |
@better0332 yes, we only identified the bug, the pull request with a partial fix (don't panic, just return an error) is not done yet. And we can't really fix this until this bugfix by @julienschmidt is integrated in Go: https://codereview.appspot.com/14920046 - and it looks like that will only take place after Go 1.2 |
fixed in #143 |
This helps with #142 The database/sql package only retries if it encounters an ErrBadConn. With errInvalidConn it returns immediately
i use git clone get new code, if I kill the mysql connection:
under linux(centos i686), it fatal.
under windows(xp, x32), it not autoreconnect
mysql version 5.1.69(contos x64)
[wanghl@localhost iVega]$ go run testdb.go
2013/10/29 15:13:29 insert 0
2013/10/29 15:13:32 insert 1
2013/10/29 15:13:35 insert 2
2013/10/29 15:13:38 insert 3
2013/10/29 15:13:41 insert 4
[MySQL] 2013/10/29 15:13:41 packets.go:30: EOF
2013/10/29 15:13:41 wanghl! driver: bad connection
2013/10/29 15:13:44 insert 5
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x1 pc=0x8078693]
goroutine 1 [running]:
github.com/go-sql-driver/mysql.(_mysqlStmt).writeExecutePacket(0x1835b900, 0x1835f330, 0x5, 0x5, 0x1, ...)
/home/wanghl/mygo/src/github.com/go-sql-driver/mysql/packets.go:818 +0x1a03
github.com/go-sql-driver/mysql.(_mysqlStmt).Exec(0x1835b900, 0x1835f330, 0x5, 0x5, 0x1835f330, ...)
/home/wanghl/mygo/src/github.com/go-sql-driver/mysql/statement.go:38 +0x41
database/sql.resultFromStatement(0x1835b960, 0x1835f180, 0x1835f1b0, 0x1835b900, 0xb73f8f00, ...)
/usr/local/go/src/pkg/database/sql/sql.go:1077 +0x1df
database/sql.(*Stmt).Exec(0x18363140, 0xb73f8f00, 0x5, 0x5, 0x0, ...)
/usr/local/go/src/pkg/database/sql/sql.go:1056 +0x13d
main.Insert(0x7, 0x5, 0x81a0108, 0x3, 0x18300488, ...)
/home/wanghl/mygo/src/iVega/testdb.go:66 +0x14c
main.main()
/home/wanghl/mygo/src/iVega/testdb.go:31 +0x269
goroutine 2 [syscall]:
exit status 2
E:\mygo>go run testdb.go
2013/10/29 15:12:57 insert 0
2013/10/29 15:13:00 insert 1
2013/10/29 15:13:03 insert 2
2013/10/29 15:13:06 insert 3
2013/10/29 15:13:09 insert 4
[MySQL] 2013/10/29 15:13:09 packets.go:31: EOF
2013/10/29 15:13:09 wanghl! driver: bad connection
2013/10/29 15:13:12 insert 5
[MySQL] 2013/10/29 15:13:12 packets.go:88: WSASend tcp 172.7.3.42:60823: An esta
blished connection was aborted by the software in your host machine.
2013/10/29 15:13:12 wanghl! driver: bad connection
2013/10/29 15:13:15 insert 6
[MySQL] 2013/10/29 15:13:15 packets.go:88: WSASend tcp 172.7.3.42:60823: An esta
blished connection was aborted by the software in your host machine.
2013/10/29 15:13:15 wanghl! driver: bad connection
2013/10/29 15:13:18 insert 7
[MySQL] 2013/10/29 15:13:18 packets.go:88: WSASend tcp 172.7.3.42:60823: An esta
blished connection was aborted by the software in your host machine.
My test code is here:
http://play.golang.org/p/XuCQ7Ug-O2
I also test Query(), it work fine
The text was updated successfully, but these errors were encountered: