-
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
"commands out of sync" errors on MySQL 8.0.24 #1393
Comments
See this topic. This is an issue that should be fixed. But it doesn't happen on healthy configuration. |
This can be caused by any error packet from the server, not just Setting |
It is server side bug. You should update server. |
Which part is the server side bug? |
Server should use sequence number 0. |
The server does use sequence number 0. The problem is when the client receives this after having incremented the sequence number. |
OK. It would be fixed in future. But it has low priority. |
For the record, official MySQL client does not handle ER_CLIENT_INTERACTION_TIMEOUT case. It just return an error if |
Issue description
This is similar to #1392 but much harder to reproduce and causes real failures.
#1392 describes the situation where the "new"
ER_CLIENT_INTERACTION_TIMEOUT
error packet is received on an idle connection. However, if you're really unlucky then it's also possible for this packet to be received just as a query is being sent. This results in anErrPktSync
("commands out of sync. You can't run this command now") error, as the sequence ID of the error packet doesn't correspond to the packet that was simultaneously written. We have seen this in at least two very busy services, and only when there are many connections hitting thewait_timeout
.What's more, this doesn't mark the connection as bad and leaves it in a "busy buffer" state, which likely causes at least one further query to fail.
I don't have any great suggestions for fixing this. Perhaps the driver could recognise that it's an error packet with a zero sequence ID, and return
ErrBadConn
in that case. At the very least, it should be able to expose the error rather than giving this "commands out of sync" error.For any readers, we fixed this by just decreasing the application level connection lifetime to be much less than
wait_timeout
.Example code
Use https://github.com/lukaszlach/docker-tc to apply a network delay to the MySQL container:
Start the MySQL container in a network, with a 1 second network delay applied:
Then this will reproduce it fairly consistently:
Error log
Configuration
Driver version (or git SHA): 1.7.0
Go version: 1.19.5
Server version: MySQL 8.0.24
Server OS: E.g. Debian 8.1 (Jessie), Windows 10
The text was updated successfully, but these errors were encountered: