Skip to content
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

Add docs on stateful context pool #3709

Merged
merged 2 commits into from
Mar 2, 2022
Merged

Add docs on stateful context pool #3709

merged 2 commits into from
Mar 2, 2022

Conversation

roji
Copy link
Member

@roji roji commented Jan 31, 2022

And rearrange the perf docs a little.

@ajcvickers would appreciate your opinion on the scoped context factory pattern shown - we've had discussions around this in the past. The one problem here is that it's not possible to register the custom Scoped factory as IDbContextFactory in DI, since that's already taken by the Singleton pooling factory (can't have the same service registered in both Scoped and Singleton).

Ideally the Singleton pooling factory wouldn't be registered as IDbContextFactory, but rather e.g. as PooledDbContextFactory; this would allow the scoped one to be registered as IDbContextFactory, and injected where multiple contexts are needed. But to do that, users would need to duplicate functionality out of e.g. EntityFrameworkServiceCollectionExtensions.AddPoolingOptions. Nothing here seems particularly bad/critical, but maybe we could improve it at some point.

Closes #3706

@roji
Copy link
Member Author

roji commented Jan 31, 2022

Also, it might be time to split out context pooling (and compiled models?) out into their own pages, they're big.

@roji roji marked this pull request as ready for review January 31, 2022 11:26
@roji roji force-pushed the PoolingWithState branch 2 times, most recently from af8c172 to cafdc7f Compare January 31, 2022 11:36
And rearrange the perf docs a little

Closes dotnet#3706
Copy link
Member

@ajcvickers ajcvickers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Given reason issues filed, maybe also add a note about not messing with the underlying ADO.NET state (DbConnection, transaction, etc.) or at least cleaning/resetting it appropriately.

@roji roji merged commit a230306 into dotnet:main Mar 2, 2022
@roji roji deleted the PoolingWithState branch March 2, 2022 09:48
@roji
Copy link
Member Author

roji commented Mar 2, 2022

@ajcvickers good idea, done.

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.

Document best practices for stateful context pooling
2 participants