-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Connection Leak with DI #2335
Comments
From @davidfowl on Sunday, September 17, 2017 5:11:54 PM
This should be a singleton. As for the other objects.. What is a DbShardContextFactory? How does the |
From @ConX-Ryan on Sunday, September 17, 2017 5:24:24 PM
Sorry that is a typo, they are meant to be the same, i was trying to clean code up for example. The DbShardContextFactory is responsible for providing a SqlConnection obj to the constructor of the ConXDbContext, it parses the request and maps a connection to a shard from the subdomain, previously it created and returned the new ConXDbContext but reading the ASP.NET Core docs because it wasnt created by the DI container it wont be disposed. Thanks for your time :) |
From @davidfowl on Sunday, September 17, 2017 5:30:02 PM I inlined the wire up here to avoid going back to the link. What's not getting disposed? |
From @ConX-Ryan on Sunday, September 17, 2017 5:35:50 PM I believe that the other repositories are being disposed in a "Scoped" fashion as expected. |
From @ConX-Ryan on Monday, September 18, 2017 2:53:24 PM I have resolved this issue by migrating to AutoFac, to use the InstancePerLifetimeScope and constructor resolution as EF needs the design time opts which lead to an ambiguous constructor error, then i am manually closing the connection in the DbShardContextFactory because even though the Dispose method is being called the connection was not closing. |
We periodically close 'discussion' issues that have not been updated in a long period of time. We apologize if this causes any inconvenience. We ask that if you are still encountering an issue, please log a new issue with updated information and we will investigate. |
…orkspace in live share scenarios. - MEF is the primary means of resolving the new live share provider therefore we allow it to not be registered. - The new contract is in the Editor.Razor binary so the LiveShare bits don't have to take the dependency on the windows binary in Razor (has a lot of baggage). - This is specific to live share but providing a generic way to resolve workspaces didn't seem reasonable given the varying expectations in VS4Mac. If we need to make a more generic solution in the future we'll revisit this; for now this is a straight forward inclusion of live share functionality. - Added tests to validate the new behavior. - This unblocks the live share scenario of resolving the remote workspace. We can't rely on the projection buffers to provide the correct workspace because that workspace is wired up too late in the process of opening a Razor file. #2335
From @ConX-Ryan on Sunday, September 17, 2017 1:17:08 PM
issuelink
I am using a single tenant config where i need to route to a customer shard based on the request. The DbShardContextFactory does this with help from the HttpContextAccessor.
Because the factory creates the DbContext instead of the DI Container it appears to not be disposing correctly even though defined as Scoped. so the .AddEntityFrameworkStores<ConXDbContext>()
call i believe is the issue
What is the correct pattern here to use the standard ASP.NET Core service collection?
I am having trouble defining the right pattern to use here, we are just migrating and what was previously working in Ninject .InRequestScope() is not the same with the in built DI.
What would be the functional equivalent pattern here?
Copied from original issue: aspnet/DependencyInjection#584
The text was updated successfully, but these errors were encountered: