-
Notifications
You must be signed in to change notification settings - Fork 877
Description
@YohDeadfall, @roji
This issue is a continuation of #3284.
It seems that the solution on #3069 helped, but it's not all that needs to be done to stop the memory consumption to grown indefinitely.
Steps to reproduce
Reproduce steps are the same as in #3284.
The issue
I observed that Npgsql.ConnectorPool is still being created multiple times for connections that have only the password changed.
I understand that one ConnectorPool should keep real live connections, but we need somehow to or delete a ConnectorPool or reuse a connector pool.
The case is the same as #3284, basically, if you leave a service running for a long time and the password changes from time to time, a new ConnectorPools will be created and will never be released, even if they have zero connections (by calling ClearAllPools).
What happens in memory is this

One option is at this point, if only the Password changed on the connection, an existing Pool should be returned:
npgsql/src/Npgsql/NpgsqlConnection.cs
Line 158 in 4aad4c0
| if (PoolManager.TryGetValue(_connectionString, out _pool)) |
This would require the consumer to clear the Pool before adding a new connection to it.
The second option would be to create an API to allow deletion of a ConnectorPool.
Further technical details
Npgsql version: 5.0.0
PostgreSQL version: 13
Operating system: Container Linux .net core 3.1