-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
database/sql: improve recovery from server timeouts #8834
Comments
Comment 4 by marko@joh.to: I've implemented what I think is a cleaner approach in https://golang.org/cl/168060044. It essentially makes maxBadConnRetries the maximum number of bad connections to discard from the pool per query, and then forces an attempt with a fresh connection after maxBadConnRetries. |
Neat idea! That probably also helps to integrate deadlines in database/sql (to support code.google.com/p/go.net/context - as proposed in https://golang.org/issue/8874). And I think maxBadConnRetries should be 1, then. |
Why maxBadConnRetries is hard coded but not a configurable option? Sometimes I do not want it to retry when connect fails. |
maxBadConnRetries isn't really about connection attempts; I'd expect a driver not to return ErrBadConn on a failed connection attempt, because it hides the error message from the user. If the user does want to retry, he/she can do it in the call outside of What's the actual use case here? |
Reties may seldom success when first attempt fails, and the latency time will be longer (e.g. ReadTimeout * 3). when maxBadConnRetrie set to 0, connection pool will actually be ignored, and maxIdleConn should also set to 0. p.s. |
by arnehormann:
The text was updated successfully, but these errors were encountered: