-
Notifications
You must be signed in to change notification settings - Fork 335
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
What's the connection lifetime in the pool? / When are idle connections released? #211
Comments
Thus, the lifetime will be controlled by the server, which should close them after |
Opened #212 to implement this connection string option. |
That explains it. I have a cluster, and after a peak of queries during startup, each node is retaining 100+ connections, exhausting the server after some nodes go up. I took a look at the Right now I have a deadline to put a get a new cluster running and I'd rather not go back to the old driver, so let me ask this: Is it possible to control this manually with ClearPool? Should there be a problem is I call ClearPoolAsync() every 10 minutes while having around 30 connections being used? And is there any way to get the number of open sessions in the pool without reflection? |
This should not be a problem at all; it will iterate over all idle connections in the pool (or all pools, if you call
There isn't a way to query MySqlConnector for how many connections it has open. (Do you know if Oracle's connector has a method to expose this? I haven't seen one.) However you could |
Do you have a cluster of App Servers, or a cluster of MySQL Servers? If you have a cluster of App Servers and a single MySQL server, you should configure your
Otherwise if you get a lot of traffic on your app servers, you could spike over the Connection Limit at any time. In the MySQL documentation for the
|
A relevant quote from Using Connector/Net with Connection Pooling:
MySqlConnector does not currently implement any logic like this; for now you could accomplish something similar by setting |
@caleblloyd, My issue is this: I have a cluster os app servers, they're not public so I can control how much work they do. But usually during startup there are a lot of queries to run, and the node easily uses more than 100 connections, then after a minute or so it gets stable to ~20. The problem is that those 80+ connections are kept open and never released. @bgrainger My worry with wait_timeout is that closing the connection on the server may cause tons of TIME_WAITs as described. I had this problem with TIME_WAITs before, and it usually requires restarting the process, so I'd rather not try this in production if there are precedents. It would be much safer to close the connections from the other side. |
@caleblloyd Now that I paid more attention to your answer, makes sense. Max Pool Size is a good enough workaround. It still maintains the problem if not closing those connections later, and will cause lots of connections to be opened and closed all the time, but at lease won't keep them hanging on the server. |
Just to make sure, |
@nvivo I just tried an experiment locally (with |
No, it does not mean that. The way Oracle implements it (and which we have followed) is that it actually enforces a maximum concurrent number of connections (for connections opened with that exact same connection string). If This seems like a strange choice to me, but it's what Oracle's connector does and I don't have a compelling rationale yet to break compatibility. I'd personally prefer to give the connector the ability to peak over If a consumer wants to limit the total simultaneous number of connections, they could implement that logic on top of MySqlConnector. And if they have multiple app servers (or even multiple processes on one server) talking to one DB, then they have to implement the limit through some other mechanism, because the |
As a workaround, your "startup" connections could use |
Oh my =) Disabling the pooling should do the trick for a while then. But yeah, I agree, it seems odd to me that "max pool size" implies "max connections". It would make more sense to have a different setting to limit that. I'll see how that goes. Thanks. |
@bgrainger So, there is one thing I was missing yesterday that you certainly know but I didn't remember. So, in effect a @caleblloyd kinda implied that, I just didn't pay attention at the time. |
You will get an exception if an idle connection is not returned to the pool within |
Hi,
I'm investigating why I'm getting more open connections with this driver than with the oracle one, and I got stuck on this question: after a connection is returned to the pool, how long does it stay idle before released?
I noticed that the original driver has the
Connection Lifetime
option, the doc says:How does it work with this driver?
The text was updated successfully, but these errors were encountered: