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
ErrBadConn can be returned only when it's safe to retry. After sending query, we can't use it.
People must use DB.SetConnMaxLifetime to avoid connection closed from MySQL server, router, middlewares, to avoid such situation.
But we can save 90% cases by checking connection liveness before sending query.
Since Go 1.9, SyscallConn can be used to call system call directly. We can try non-blocking 1-byte read to detect connection closed by peer.
There are some drawbacks.
I'm not sure this is good idea. MySQL Connectors don't implement such checks.
All languages should keep connection fresh in pool.
ErrBadConn
can be returned only when it's safe to retry. After sending query, we can't use it.People must use
DB.SetConnMaxLifetime
to avoid connection closed from MySQL server, router, middlewares, to avoid such situation.But we can save 90% cases by checking connection liveness before sending query.
Since Go 1.9, SyscallConn can be used to call system call directly. We can try non-blocking 1-byte read to detect connection closed by peer.
Ref: #657
Ref: golang/go#28607
The text was updated successfully, but these errors were encountered: