Skip to content

Add some connection string checks for Npgsql - #419

Merged
sebastienros merged 1 commit into
aspnet:devfrom
roji:npgsql-checks
Apr 6, 2018
Merged

sebastienros merged 1 commit into
aspnet:devfrom
roji:npgsql-checks

Conversation

@roji

@roji roji commented Mar 19, 2018

Copy link
Copy Markdown
Member

To make sure we're in high-perf mode.

/cc @sebastienros

Is it possible to also add something similar to https://github.com/aspnet/FrameworkBenchmarks to prevent accidental runs with non-optimized connection strings?

To make sure we're in high-perf mode
@roji

roji commented Apr 1, 2018

Copy link
Copy Markdown
Member Author

Ping, in the default mode Npgsql will attempt to enlist to an ambient TransactionScope, which will reduce Open() perf, so it's important to make sure this doesn't happen in the benchmarks...

@sebastienros

Copy link
Copy Markdown
Member

I already started to apply the connection string changes first, otherwise it would blow up existing scenarios.
I will soon be able to merge it (as I restart the servers I apply it).

However I thought that the value was false by default, I looked at the documentation.

@roji

roji commented Apr 2, 2018

Copy link
Copy Markdown
Member Author

It's true that it was off by default, but I've changed this for 4.0.0 - see the discussion in npgsql/npgsql#1483. I've updated the performance page in the docs to make sure people know to disable enlist in "high perf mode". However the docs on npgsql.org are still for 3.2, this is why you're still seeing that it's false by default.

That's why I'm submitting this PR :)

@sebastienros

Copy link
Copy Markdown
Member

I had all my connection strings updates, then switched to 4.0 preview 1, and started seeing runtime issues. I am almost sure these errors where not there last week when I was measuring it.

[01:07:31.299] System.TypeLoadException: Could not load type 'Npgsql.TypeMappingAttribute' from assembly 'Npgsql, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7'.
[01:07:31.299]    at Microsoft.EntityFrameworkCore.Storage.Internal.NpgsqlEFTypeMapper..ctor(RelationalTypeMapperDependencies dependencies)
[01:07:31.299] --- End of stack trace from previous location where exception was thrown ---
[01:07:31.299]    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEng
ineScope scope)
[01:07:31.299]    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
[01:07:31.299]    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEng
ineScope scope)
[01:07:31.299]    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
[01:07:31.299]    at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
[01:07:31.299]    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
[01:07:31.312]    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEng
ineScope scope)
[01:07:31.312]    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
[01:07:31.312]    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEng
ineScope scope)
[01:07:31.312]    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)

Let me know if you think this is an issue in EF, I can file it.

@roji

roji commented Apr 3, 2018

Copy link
Copy Markdown
Member Author

I'm guessing that you're trying to use Npgsql.EntityFrameworkCore.PostgreSQL 2.0.x with Npgsql 4.0.0-preview1, right? There have been some breaking changes (at least for now) so EFCore.PG 2.0 will only work with Npgsql 3.2, and EFCore.PG 2.1 awill only work with Npgsql 4.0 - the idea is to align them and release Npgsql 4.0 at the same time as EFCore 2.1.

Have you tried using EFCore 2.1.0-preview1 with Npgsql 4.0?

Regardless, that shouldn't stop you from changing Enlist in the connection string. I'd also really recommend adding a check internally that enlist is false, otherwise someone may accidentally run without Enlist=false in the future.

@sebastienros

Copy link
Copy Markdown
Member

Correct, I can merge this PR. Just waiting to restart the long running jobs. Should be done by tomorrow morning.

@sebastienros
sebastienros merged commit a4df533 into aspnet:dev Apr 6, 2018
@roji
roji deleted the npgsql-checks branch September 23, 2022 17:05
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.

2 participants