-
Notifications
You must be signed in to change notification settings - Fork 227
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
Using NpgsqlDataSource in DependencyInjection pollutes other containers #2891
Comments
Thanks @eerhardt, I'll look into this very soon. |
* Delay connection validation When an app is deployed to a new environment, it is common for the connection information to be missing initially. When this is the case, the app crashes very early (inline when calling AddXXX for the component). When throwing this early, there isn't an ILogger which can log the exception, and thus the exception is written to stderr/stdout by the .NET runtime. This isn't ideal since certain environments expect stdout logs to be in a certain format. The fix is to delay the connection validation until the underlying DI service is requested/created. At this point the DI container is built, and the app can log an exception with the configured ILogger. Fix #185 * Work around npgsql/efcore.pg#2891
This test randomly fails because of npgsql/efcore.pg#2891. Disabling it until that bug is fixed. Fix #496 Contributes to #365
This test randomly fails because of npgsql/efcore.pg#2891. Disabling it until that bug is fixed. Fix #496 Contributes to #365
Fixes npgsql#2891 Fixes npgsql#3063 Fixes npgsql#1026 Co-authored-by: Nino Floris <[email protected]>
Fixes npgsql#2891 Fixes npgsql#3063 Fixes npgsql#1026 Co-authored-by: Nino Floris <[email protected]>
Fixes npgsql#2891 Fixes npgsql#3063 Fixes npgsql#1026 Co-authored-by: Nino Floris <[email protected]>
Fixes npgsql#2891 Fixes npgsql#3063 Fixes npgsql#1026 Co-authored-by: Nino Floris <[email protected]>
…3167) Fixes #2891 Fixes #3063 Fixes #1026 Co-authored-by: Nino Floris <[email protected]>
@eerhardt did a comprehensive overhaul of how DbDataSource is handled in the provider, all leaks should now be gone. |
Thanks for fixing this. I can confirm that #3043 is working properly now when using EF Core 9 preview 3 with the MyGet feed from https://www.myget.org/F/npgsql-vnext/api/v3/index.json (Npgsql.DependencyInjection v9.0.0-preview.1-ci.20240519T065219 and Npgsql.EntityFrameworkCore.PostgreSQL v9.0.0-preview.4-ci.20240518T175510). Just wondering: is there any chance this will be backported to EF Core 8? |
Ok sure, no problem. We'll wait until EF Core 9 then, before using this. |
Running the following program:
produces an error on the 2nd test run:
The connection string is reused across DI containers. As far as I can tell, it is because:
https://github.com/dotnet/efcore/blob/5299be3bfeab62224f29aae9d4adff510878fcf7/src/EFCore/Internal/ServiceProviderCache.cs#L68-L71
So DbContextOptions between 2 different DbContexts equal, and the stuff cached for the first context (like the
INpgsqlSingletonOptions
) are being reused across different DI containerscc @roji
The text was updated successfully, but these errors were encountered: