You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #1393, I described a situation that can frequently cause ErrPktSync errors in very busy services, when the local timeout is greater than the wait_timeout.
In one service, we saw this triggering huge bursts of "busy buffer" log messages and "invalid connection" errors. This is because:
When we get an ErrPktSync error here, the connection is not closed and the buffer is left filled.
The connection is then returned to the pool, because IsValid() returns true (because the connection is not closed).
When the connection is taken from the pool, ResetSession() doesn't reset the buffer.
If the buffer isn't empty, interpolateParams()returns ErrInvalidConn without closing the connection, which brings us back to step 2.
Almost 100% of our queries were using interpolateParams, so we'd essentially get stuck in this cycle until the connection timed out.
It seems like one of the simplest things to do might be to clear the buffer in ResetSession(), since it's only at that point we know that any previous queries are no longer relevant.
Issue description
In #1393, I described a situation that can frequently cause
ErrPktSync
errors in very busy services, when the local timeout is greater than thewait_timeout
.In one service, we saw this triggering huge bursts of "busy buffer" log messages and "invalid connection" errors. This is because:
ErrPktSync
error here, the connection is not closed and the buffer is left filled.IsValid()
returnstrue
(because the connection is not closed).ResetSession()
doesn't reset the buffer.interpolateParams()
returnsErrInvalidConn
without closing the connection, which brings us back to step 2.Almost 100% of our queries were using
interpolateParams
, so we'd essentially get stuck in this cycle until the connection timed out.It seems like one of the simplest things to do might be to clear the buffer in
ResetSession()
, since it's only at that point we know that any previous queries are no longer relevant.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:
Error log
Configuration
Driver version (or git SHA): 1.7.0
Go version: 1.19.5
Server version: MySQL 8.0.24
Server OS: Ubuntu 18.04.1
The text was updated successfully, but these errors were encountered: