-
Notifications
You must be signed in to change notification settings - Fork 2.3k
On server restart clients get this error: MySQL error: commands out of sync. You can't run this command now #449
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
I've been having a play with the source code and narrowed the issue down to line https://github.com/go-sql-driver/mysql/blob/master/packets.go#L48 If I put this small change in place after
Is this OK do you think or does it break something else? Thanks |
See #302. |
Is this fixed now since we merged #302? |
Is this fixed? I encountered the same issue |
I don't think we will "fix" this issue because it's just an expected behavior. When using connection pool, restarting server will cause some errors on client side. True solutions are:
|
@sewi-cpan Have you used SetConnMaxLifetime? When using this driver, I think short SetConnMaxLifetime is mandatory. |
Issue description
When using a persistent connection to a MySQL server, if the server is restarted, the old connection is left in a CLOSE_WAIT state on the client (suggesting the Go program has not detected the socket was closed).
E.g.
This means that the next time the Go program tries to run a query, the dead connection is used and we get the error:
MySQL error: commands out of sync. You can't run this command now
The dead connection is then removed by the SQL drive and reconnects to the server.
Further queries run OK.
Example code
Error log
Configuration
Driver version (or git SHA):
"ImportPath": "github.com/go-sql-driver/mysql",
"Comment": "v1.2-194-g7ebe0a5",
"Rev": "7ebe0a500653eeb1859664bed5e48dec1e164e73"
Go version: run
go version
in your consolego version go1.6.2 linux/amd64
Server version: E.g. MySQL 5.6, MariaDB 10.0.20
Server version: 10.0.24-MariaDB MariaDB Server
Server OS: E.g. Debian 8.1 (Jessie), Windows 10
CentOS 6.7 x86_64
The text was updated successfully, but these errors were encountered: