-
Notifications
You must be signed in to change notification settings - Fork 0
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
Shared DbContext causing concurrency-related exception #193
Comments
There may not be an ideal solution this. The problem is doing this while limiting unnecessary trips to the database. The only way that seems feasible is to track changes manually. This is how this was handled in a similar scenario here. Using a stack-like structure would also assist with managing 'undo/redo' requests for changes. Might need to keep that to only reversing deletes for the sake of time/priorities. Issue dotnet/efcore#5536 discusses creation of something for out of the box, so keep it mind. |
…tion<T> Add CollectionCommand and CollectionCommandHistory tracking for working forwards and backwards through 'undo' and 'redo' operations. Supports changes to entity model services responsible for adding/removing/updating multiple entities at once. Related #193
…rvices Remove the persisted DbContext classes in the entity model service layer and replace with correct short-lived used of DbContext-derived classes. Introduces ChangeTracking for a disconnected collection of entities to be worked in batches of not more than a single page size. Update tracking is not available. Related #193
Changes pages that work with collections of entities to inherit from ModelListPage and use the updated controller interface ICollectionController. Completes work necessary to support pagination without crashing due to multi-threaded access to DbContext classes. Resolves #193
* refactor(DAL): remove obsolete services Remove entity model services where the models will be maintained via a parent object service. * test(DAL): remove tests for obsolete entity model services * refactor(Controller): remove obsolete entity model controllers * refactor(Blazor): remove unnecessary lock object * feat(DAL): add class for tracking add/remove operations on an ICollection<T> Add CollectionCommand and CollectionCommandHistory tracking for working forwards and backwards through 'undo' and 'redo' operations. Supports changes to entity model services responsible for adding/removing/updating multiple entities at once. Related #193 * test(DAL): add tests for CollectionCommandHistory class * refactor(DAL): remove obsolete CountryBatchWriterService * refactor(DAL): refactor ICollectionCommandHistory and CommandHistoryEntry Rename ICollectionCommandHistory to ICommandHistory. Move CommandHistoryEntry to separate file. * feat(DAL): add Clear method to ICommandHistory interface * test(DAL): add test for ICommandHistory.Clear method * feat(DAL): make ICommandHistory generic Convert ICommandHistory to generic interface and update implementation. Rename CollectionCommandHistory to CommandHistory. * feat(DAL): add IChangeTracker implementation ot CommandHistory Update CommandHistory to implement IChangeTracker. Class features are not exactly aligned, but this approach was most expedient. Opportunity to refactor later. * test(DAL): fix test name add tests for IChangeTracker methods Rename CollectionCommandHistoryTest to CommandHistoryTest to mirror tested class. Add tests for IChangeTracker methods implemented in CommandHistory<T>. * feat(DAL): consolidate methods in IChangeTracker and ModelCollectionService Add ModelCollectionService to replace ModelWriterBatchService and ModeBatchService class. ModelCollectionServices implements add/remove change tracking for a disconnected entity set. * fix(DAL): add missing resource file * test(DAL): update IChangeTracker tests to use new GetChanges method * feat(EntityModel): change DatabaseKey to a public extension method * fix(DAL) remove shared and persisted DbContext classes from entity services Remove the persisted DbContext classes in the entity model service layer and replace with correct short-lived used of DbContext-derived classes. Introduces ChangeTracking for a disconnected collection of entities to be worked in batches of not more than a single page size. Update tracking is not available. Related #193 * test(DAL): fix tests related to removed IModelBatchService interface * fix(Controllers): fix controller referneces to IModelBatchController * refactor(DAL): move IModelCollectionService to separate file * fix(DAL): resolve errors in service registration * fix(Blazor): update collection pages to inherit ModelListPage Changes pages that work with collections of entities to inherit from ModelListPage and use the updated controller interface ICollectionController. Completes work necessary to support pagination without crashing due to multi-threaded access to DbContext classes. Resolves #193 * refactor(Blazor): move most page initialization methods to base class Move majority of page initialization logic to base classes ModelListPage, ModelIndex, and ModelPagedIndex. Prepares the UI layer for application of Paginator control. * fix(DAL): fix missing constructor arguments for SecurityExchangeBatchService * refactor(DAL): standardize names for ModelCollectionService classes * feat(Blazor): add paginator control to base index pages * design(Blazor): fix form-control.button rule to preserve size of button icons * feat(Blazor): add paginator control to remaining collection pages
Describe the bug
Non-thread-safe use of
FinanceDbContext
can create scenarios where multiple select statements are called concurrently, throwing anInvalidOperationExcpetion
.To Reproduce
Steps to reproduce the behavior:
Pagination.razor
component, quickly page through results.Expected behavior
Note the docs indicate that
DbContext
is not thread-safe, and should be disposed after each instance. This needs to be better handled by the service layer so that disconnected entities may be used.Bug-reproducing version can be found at commit ccc8493.
The text was updated successfully, but these errors were encountered: