Skip to content

Fix connection leak in NpgsqlDatabaseCreator.Exists - #1813

Merged
roji merged 1 commit into
mainfrom
FixExistsConnectionLeak
Apr 17, 2021
Merged

roji merged 1 commit into
mainfrom
FixExistsConnectionLeak

Conversation

@roji

@roji roji commented Apr 17, 2021

Copy link
Copy Markdown
Member

Fixes #1812

This is a workaround; the root issue here is that NpgsqlRelationalConnection.CloneWith returns an instance with _connectionOwned=false, since the NpgsqlConnection is externally-provided. This means that disposing the NpgsqlRelationalConnection does not close/dispose the NpgsqlConnection, hence the leak.

Ideally CloneWith should return an instance with _connectionOwned=true.

@roji
roji enabled auto-merge (squash) April 17, 2021 17:37
@roji
roji merged commit 1d28c41 into main Apr 17, 2021
@roji
roji deleted the FixExistsConnectionLeak branch April 17, 2021 17:46
roji added a commit that referenced this pull request Apr 17, 2021
@roji

roji commented Apr 17, 2021

Copy link
Copy Markdown
Member Author

Backported to 5.0.6 via 4213899

@frabe1579

Copy link
Copy Markdown

I can confirm that this fix resolves #1812 .
Tested with Npgsql.EntityFrameworkCore.PostgreSQL v5.0.6-ci.20210417T175903.

Thanks!

@roji

roji commented Apr 18, 2021

Copy link
Copy Markdown
Member Author

Thanks for testing and reporting @frabe1579! You can use that CI package until 5.0.6 comes out (which shouldn't be on too long).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CanConnectAsync does not correctly dispose connection when pooling is active

2 participants