A second operation starte d on this context before a previous operation completed
See original GitHub issue- Abp package version 4.5.0.
- .Net Core2.2. I use a timer at the reference layer to collect some serial port data and then use the event bus to process the data.Now I find that the program runs for a while and occasionally has a problem:
Unhandled Exception: System.InvalidOperationException: A second operation starte
d on this context before a previous operation completed. This is usually caused
by different threads using the same instance of DbContext, however instance memb
ers are not guaranteed to be thread safe. This could also be caused by a nested
query being evaluated on the client, if this is the case rewrite the query avoid
ing nested invocations.
at Microsoft.EntityFrameworkCore.Internal.ConcurrencyDetector.EnterCriticalSe
ction()
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveCha
nges(IReadOnlyList1 entriesToSave) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveCha nges(Boolean acceptAllChangesOnSuccess) at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChang esOnSuccess) at Abp.EntityFrameworkCore.AbpDbContext.SaveChanges() at Abp.Zero.EntityFrameworkCore.AbpZeroCommonDbContext
3.SaveChanges()
at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.SaveChangesInDbContext(DbCont
ext dbContext)
at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.SaveChanges()
at Abp.EntityFrameworkCore.AbpDbContext.SaveChanges()
at Abp.Zero.EntityFrameworkCore.AbpZeroCommonDbContext`3.SaveChanges()
at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.SaveChangesInDbContext(DbCont
ext dbContext)
at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.SaveChanges()
at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.CompleteUow()
at Abp.Domain.Uow.UnitOfWorkBase.Complete()
at Abp.Domain.Uow.UnitOfWorkInterceptor.PerformSyncUow(IInvocation invocation
, UnitOfWorkOptions options)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at SensorBroker.Schedules.CompositeSensor.CompositeSensorCommunicatorHandler.
OnParseData(Object state) in D:\SVN\VR-Code\Trunk\SensorBroker\Source\sensorbrok
er-aspnet-core\src\SensorBroker.Application\Schedules\CompositeSensor\CompositeS
ensorCommunicatorHandler.cs:line 144
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
You can try using AsyncHelper.RunSync() instead of Wait()