-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Added maxBadConnRetries to limit the number of times to obtain broken… #1837
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
Conversation
… connections. Signed-off-by: monkey92t <[email protected]>
This is an improvement to #1824. |
Signed-off-by: monkey92t <[email protected]>
Signed-off-by: monkey92t <[email protected]>
@@ -235,7 +239,7 @@ func (p *ConnPool) Get(ctx context.Context) (*Conn, error) { | |||
return nil, err | |||
} | |||
|
|||
for { | |||
for i := 0; i < maxBadConnRetries; i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I see that you already realize this :)
I think that with this change we may open more than I guess we should introduce something like Speaking about v9. I think it is time we start thinking about releasing first beta version so we can start testing it. But before that we should remove/replace deprecated APIs. Could you take care of that? |
I don't quite understand what you mean, there are only two situations where you can create a new connection:
In both cases, there is no problem creating a new connection. I agree with Compared to v8.11.0, we have recently added (or fixed) some features, and we need to consider releasing a new version. |
Well, you can't create new connections having idle connections in the pool. Otherwise you have > PoolSzie connections in the pool which almost certainly breaks the pool, because
I am not sure it is a big problem since |
I still can’t understand. When I closed maxBadConnRetries=2 connections and created a new connection, why would the connection pool overflow (> PoolSize)? Suppose now len(idleConns) = 10, maxBadConnRetries=2,
After execution, len(idleConns) = 8, it seems that there is no problem in creating a new connection. |
OK, I just think it is risky, if you think there is nothing wrong with it, we can close this issue. |
There were 8 idle conns at some point in the past, but in the next instant there can be 100 or 0 idle connections because there are other threads that can add/remove connections. The pool is synchronized around
Hopefully that helps. |
This PR is not intended to solve #1737.
It is to limit the number of attempts. If all connections in a connection pool fail, we should not let it detect all connections in the entire connection pool.