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
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
1.6
What operating system and processor architecture are you using (go env)?
Linux x86
What did you do?
Set db connections to expire:
db.SetConnMaxLifetime(5 * time.Minute)
Create some connections, use them, and occasionally call db.Ping().
What did you expect to see?
Ping returning nil.
What did you see instead?
Ping returning ErrBadConn.
There are two problems here. The major problem is that conn() with strategy cachedOrNewConn isn't very tolerant of expired connections in the pool, and returns an error if the first connection happens to be expired. I think conn() should loop through all connections in the pool looking for an unexpired one, and then fall back to creating a new one if there are no unexpired ones available.
The secondary problem is that Ping() isn't very tolerant of conn(cachedOrNewConn) failures. Most other functions that call this (e.g. Prepare, Exec, Query) do so in a loop for maxBadConnRetries, but Ping doesn't have this retry logic. Therefore users of Ping() are more susceptible to spurious errors.
The text was updated successfully, but these errors were encountered:
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?1.6
What operating system and processor architecture are you using (
go env
)?Linux x86
What did you do?
Set db connections to expire:
Create some connections, use them, and occasionally call db.Ping().
What did you expect to see?
Ping returning nil.
What did you see instead?
Ping returning ErrBadConn.
There are two problems here. The major problem is that conn() with strategy cachedOrNewConn isn't very tolerant of expired connections in the pool, and returns an error if the first connection happens to be expired. I think conn() should loop through all connections in the pool looking for an unexpired one, and then fall back to creating a new one if there are no unexpired ones available.
The secondary problem is that Ping() isn't very tolerant of conn(cachedOrNewConn) failures. Most other functions that call this (e.g. Prepare, Exec, Query) do so in a loop for maxBadConnRetries, but Ping doesn't have this retry logic. Therefore users of Ping() are more susceptible to spurious errors.
The text was updated successfully, but these errors were encountered: