denisenkom / go-mssqldb

Microsoft SQL server driver written in go language
BSD 3-Clause "New" or "Revised" License
1.82k stars 495 forks source link

panic: driver.ErrBadConn in checkBadConn. This should not happen #693

Closed ondi closed 2 years ago

ondi commented 3 years ago

Describe the bug panic

panic: driver.ErrBadConn in checkBadConn. This should not happen.goroutine 201 [running]:github.com/denisenkom/go-mssqldb.(*Conn).checkBadConn(...) /go/pkg/mod/github.com/denisenkom/go-mssqldb@v0.10.0/mssql.go:183github.com/denisenkom/go-mssqldb.(*Stmt).exec(0xc000805020, {0xd44e58, 0xc000805200}, {0x133e578, 0xbbe080, 0xc003781001}) /go/pkg/mod/github.com/denisenkom/go-mssqldb@v0.10.0/mssql.go:647 +0x2f6github.com/denisenkom/go-mssqldb.(*Stmt).ExecContext(0xc000805020, {0xd44e58, 0xc000805200}, {0x133e578, 0x0, 0xc004a5b5f0})    /go/pkg/mod/github.com/denisenkom/go-mssqldb@v0.10.0/mssql.go:974 +0xd5contrib.go.opencensus.io/integrations/ocsql.ocStmt.ExecContext({{0xd44f70, 0xc000805020}, {0xc0007a0a00, 0x3336}, {0x1, 0x1, 0x1, 0x1, 0x1, 0x1, ...}}, ...) /go/pkg/mod/contrib.go.opencensus.io/integrations/ocsql@v0.1.7/driver.go:733 +0x6b2database/sql.ctxDriverStmtExec({0xd44de8, 0xc0001a8000}, {0xd45c58, 0xc000805080}, {0x133e578, 0x0, 0x0})    /usr/local/go/src/database/sql/ctxutil.go:65 +0x132database/sql.resultFromStatement({0xd44de8, 0xc0001a8000}, {0xd3f9c8, 0xc00168e7e0}, 0xc003349bf8, {0x0, 0x0, 0x0})  /usr/local/go/src/database/sql/sql.go:2622 +0x145database/sql.(*DB).execDC(0x1, {0xd44de8, 0xc0001a8000}, 0xc0055c8900, 0x3336, {0xc0007a0a00, 0x3336}, {0x0, 0x0, 0x0})    /usr/local/go/src/database/sql/sql.go:1665 +0x485database/sql.(*DB).exec(0x452549, {0xd44de8, 0xc0001a8000}, {0xc0007a0a00, 0x3336}, {0x0, 0x0, 0x0}, 0x20) /usr/local/go/src/database/sql/sql.go:1626 +0xe8database/sql.(*DB).ExecContext(0xc80893, {0xd44de8, 0xc0001a8000}, {0xc0007a0a00, 0x3336}, {0x0, 0x0, 0x0}) /usr/local/go/src/database/sql/sql.go:1601

To Reproduce long running server error

Expected behavior no panic

Further technical details

SQL Server version: (e.g. SQL Server 2017) Operating system: Fedora 34 go version devel go1.18-f118d145a5 Tue Aug 31 08:41:16 2021 +0000 linux/amd64

Additional context Add any other context about the problem here.

kevinyjn commented 2 years ago

I got this bug too, this issue happens frequently in kubernetes+istio environment

fineol commented 2 years ago

Ondi, I see that you are running v0.10.0 from your stack trace. When did you first start seeing this problem?

Kevinyjn, could you include the full panic message that you receive? And when did you first start seeing the problem?

fineol commented 2 years ago

I believe I see the problem. I will issue a pull request with a fix.

fineol commented 2 years ago

As it turns out, this was corrected with pull request #662 on July 8, 2021. Please update to commit b59767277ee66eb0b711fe8f042bfb5a1b1da70e or later. The fix is not yet contained in any tagged release.

kardianos commented 2 years ago

I've tagged a new release.

kevinyjn commented 2 years ago

Ondi, I see that you are running v0.10.0 from your stack trace. When did you first start seeing this problem?

Kevinyjn, could you include the full panic message that you receive? And when did you first start seeing the problem?

panic: driver.ErrBadConn in checkBadConn. This should not happen. github.com/denisenkom/go-mssqldb.(Conn).checkBadConn(0xc001aa3110, 0x1d4fac0, 0xc00003ce30, 0x0, 0x0) /go/pkg/mod/github.com/denisenkom/go-mssqldb@v0.10.0/mssql.go:183 +0x1cf github.com/denisenkom/go-mssqldb.(Stmt).exec(0xc002e45c58, 0x1d78e00, 0xc0038aaf60, 0x29187f8, 0x0, 0x0, 0x7f6f7002a220, 0xc002e45bd8, 0xcfbef1, 0xc001e42260) /go/pkg/mod/github.com/denisenkom/go-mssqldb@v0.10.0/mssql.go:647 +0xc5 github.com/denisenkom/go-mssqldb.(Stmt).ExecContext(0xc002e45c58, 0x1d78e00, 0xc0038aaf60, 0x0, 0x0, 0x0, 0x420450, 0xc015d98a70, 0x10, 0x1) /go/pkg/mod/github.com/denisenkom/go-mssqldb@v0.10.0/mssql.go:974 +0x169 github.com/denisenkom/go-mssqldb.(Conn).Ping(0xc001aa3110, 0x1d78e00, 0xc0038aaf60, 0x0, 0xc00006f800) /go/pkg/mod/github.com/denisenkom/go-mssqldb@v0.10.0/mssql.go:899 +0x99