-
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
Likely race that can prevent to recycle closed connections #1542
Comments
I went ahead and Ive created a PR #1545 let me know what you think 🙇 |
Did you see |
#1513 may be same issue. But I don't know because no reproduce step yet. |
Unfortunately we did not have the logger configured and we never sent the stderr to our central logs, we will make sure that we configure it in a way that allow us to gather these kind of logs later.
Yes, I would say that #1513 suffered from a similar issue which could have been triggered from the same scenario that I was describing |
We have upgraded our mysql client from 1.2.0 to 1.7.1 recently, and after a while we have observed that one of our instances that was running the client started to fail for all of the operations with an error that was saying
invalid connection
.This error seemed to come from here
Our initial guess was that an unhealthy TCP connection was used all the time, and for some reason the TCP connection was not automatically recycled due to its supposed closing state.
We have found out that from the 1.2.0 version to the 1.7.1 there was this PR which changed drastically the way that the mysql driver was informing to the SQL Golang connection pool that connections were considered in bad state, and they should be recycled from the pool.
While the original changes seemed legit, with the propose of preventing retries for operations that might already touched the server, we found out that this was also changed. So returning the internal
ErrInvalidConn
in case the buffer could not be taken.We could not yet reproduce the issue but we believe that some scenarios could lead to a situation where the
length
of the buffer is not 0, and the interpolation can not be done. For example consider the following scenario:ErrInvalidConn
will be returned in that caseAs I said we could not yet probe that this was the root cause of the original issue, but seemed a plausible scenario that could have lead to the situation that we experimented.
Also you might want to consider if its semantically correct to return the
ErrInvalidConn
when the sever was not yet touched, considering maybe on just returning thedriver.ErrBadConn
which would automatically resolve any issue with unhealthy TCP connections.Let me know what you think, we are more than happy to create a PR with this change if you believe that its worth it.
The text was updated successfully, but these errors were encountered: