-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Driver: invalid connection #654
Comments
It is intentional. When ErrBadConn is returned, database/sql will retry. |
@methane, but driver return err not equals to ErrBadConn. and close connection, but in standard lib ,the connection would be put back into pool, next time i would get a connection which had been close before and err invalid connection would happened. |
Yes, and retried.
And retried transparently.
It may cause more critical result. SELECT 1; -- if this query cancelled, |
close connection or not, put back or not. driver should do the same behavior with standard Lib.
should be change to below in standard lib.
|
I can't get what your said. "Return ErrBadConn next time" is best way for now. |
see also: golang/go#11978 (comment) |
may resolve. |
Issue description
Func (mc *mysqlConn)watchCancel() set var watching to true when conn request timeout and return err context deadline exceeded, exec mc.cleanup() to close the connection.but in standard lib, only when err equal to ErrBadConn ,the conn would be closed. Otherwise, err would be ignored and connection will be put back into conn pool.Next time I get connection from conn pool, I would get a bad connection which had been close by driver because of err deadline exceeded.
Example code
In go-sql-driver
But in standard Lib. function putConn would put conn back to pool unless err equal to ErrBadConn:
https://github.com/golang/go/blob/release-branch.go1.8/src/database/sql/sql.go#L1032.
Otherwise, err would be ignored at https://github.com/golang/go/blob/release-branch.go1.8/src/database/sql/sql.go#L1045 and conn would be put back into pool.
Error log
Configuration
*Driver version (or git SHA):i3UtE7/Cn57eX1hO5Z0CqY/Eeb4=
*Go version: go1.8.3 darwin/amd64
*Server version: MySQL 5.6, MariaDB 10.0.20
*Server OS: darwin/amd64
The text was updated successfully, but these errors were encountered: