Skip to content
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

Connection pool leak #836

Closed
alexalok opened this issue Jun 24, 2020 · 2 comments
Closed

Connection pool leak #836

alexalok opened this issue Jun 24, 2020 · 2 comments
Labels
Milestone

Comments

@alexalok
Copy link

alexalok commented Jun 24, 2020

I have faced an "Too Many Connections" exception and while working on a fix have noticed that one of the queries was sometimes timing out (cause is not related to the library). That query runs periodically and opens a new connection on every run. Since we have a pooling mechanism enabled, it usually just grabs one of the pool connections and releases it after some time. However if query times out then the pool connection is not released. Please see the following extract from the logs:

...
2020/06/23 15:15:01.179|INFO|ServerSession|Session1.1 failed in ReceiveReplyAsync|The Command Timeout expired before the operation completed.
2020/06/23 15:15:01.179|INFO|ServerSession|Session1.1 setting state to Failed|The Command Timeout expired before the operation completed.
2020/06/23 15:15:01.179|INFO|ServerSession|Session1.1 setting state to Failed|The Command Timeout expired before the operation completed.
2020/06/23 15:15:01.179|DEBUG|ServerSession|Session1.1 entering FinishQuerying; SessionState=Failed|
2020/06/23 15:15:02.100|DEBUG|ConnectionPool|Pool1 reaping connection pool|
2020/06/23 15:15:02.100|DEBUG|ConnectionPool|Pool1 recovered no sessions|
2020/06/23 15:15:03.193|DEBUG|ConnectionPool|Pool1 waiting for an available session|
2020/06/23 15:15:03.193|DEBUG|ConnectionPool|Pool1 found an existing session; checking it for validity|
2020/06/23 15:15:03.193|DEBUG|ServerSession|Session1.3 ServerVersion=8.0.19 supports reset connection; sending reset connection request|
2020/06/23 15:15:03.193|DEBUG|ConnectionPool|Pool1 returning pooled Session1.3 to caller; LeasedSessionsCount=3|
...

As you can see, Session1.1 is in a failed state now but it still counts in LeasedSessionsCount. After some time, more and more pool connections move to a failed state and accumulate in LeasedSessionsCount until the limit is reached. I also believe those connections are in a closed state because I do not see a gradual increase in active connections on the server's side.

Perhaps I'm missing something and there is a setting to force such connections to be reaped as well? I would appreciate any feedback on this matter.


MySqlConnector version: 0.61.0
MySQL server version: 8.0.19
.NET version: .NET Core 3.1

@bgrainger bgrainger added the bug label Jun 25, 2020
@bgrainger
Copy link
Member

bgrainger commented Jun 25, 2020

It seems like this might have been a bug introduced in these two lines: 7cad67e#diff-3376e8cc83a80319bfa3b795bd054c00R651-R652

@bgrainger bgrainger added this to the 1.0 milestone Jun 25, 2020
@bgrainger
Copy link
Member

bgrainger commented Jun 25, 2020

Fixed in 0.69.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants