Bug #96836 Increased sleeping connections due to additional connection pool being created
Submitted: 11 Sep 2019 10:49 Modified: 2 Mar 2020 14:55
Reporter: Rodrigo Rueda Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:8.0.17 OS:Windows
Assigned to: CPU Architecture:Any
Tags: connection pool, entity framework

[11 Sep 2019 10:49] Rodrigo Rueda
Description:
During some tests I've noticed various sleeping connections on the server side, all with no database set. After some investigation, I've come to find that in order to determine the server version, .net connector instances a connection with a modified connection string where database is set to null (line 239 at mysql-connector-net\EntityFramework\src\ProviderServices.cs, method GetDbProviderManifestToken), which forces the creation of an additional pool with such connection string.

This is specially bad for applications that set minimumpoolsize as we end up with minimumpoolsize sleeping connections only wasting server resources.

How to repeat:
- Connection string configured with minimumpoolsize and database name;
- Use entity framework DbContext to connect to the database;
- Notice 2 * minimumpoolsize connections at the server side, half pointing to no database and half pointing to the database defined in the connection string.

Suggested fix:
I'm not sure about the impact, but assuming that GetDbProviderManifestToken is not called many times, setting pooling to false besides setting database to null on that connection might do the trick.