Skip to content

Make ClearAllPools complete remove pools from memory #3387

@loe-lobo

Description

@loe-lobo

@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
ConnectorPool

One option is at this point, if only the Password changed on the connection, an existing Pool should be returned:

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions