Prerequisites
- What is your product type (Angular or MVC)? MVC
- What is product framework type (.net framework or .net core)? .Net CORE 3.1
If issue related with ABP Framework
- What is ABP Framework version? 9.0.1
In some cases, in production enviroment, the server is throwing exception AbpDbConcurrencyException on InsertAndGetId() method.
I cannot reproduce this error and I have no idea what is wrong. It doesn't happen always, it is intermittent.
I wonder if there is some way to figure out what is wrong and fix it.
Exception:
Abp.Domain.Uow.AbpDbConcurrencyException: Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.
---> Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException: Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.
at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ThrowAggregateUpdateConcurrencyException(Int32 commandIndex, Int32 expectedRowsAffected, Int32 rowsAffected)
at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ConsumeResultSetWithoutPropagationAsync(Int32 commandIndex, RelationalDataReader reader, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ConsumeAsync(RelationalDataReader reader, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable
1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList1 entriesToSave, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(DbContext _, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func
4 operation, Func4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Abp.EntityFrameworkCore.AbpDbContext.SaveChangesAsync(CancellationToken cancellationToken) --- End of inner exception stack trace --- at Abp.EntityFrameworkCore.AbpDbContext.SaveChangesAsync(CancellationToken cancellationToken) at Abp.Zero.EntityFrameworkCore.AbpZeroCommonDbContext
3.SaveChangesAsync(CancellationToken cancellationToken)
at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase3.InsertAndGetIdAsync(TEntity entity) at Abp.Domain.Uow.UnitOfWorkInterceptor.InternalInterceptAsynchronous[TResult](IInvocation invocation) at ASL.iAPIS.ApiaryProjectCustomApp.ApiaryActionsService.CreateTasksInternalAsync(CreateTaskDto createTasks, List
1 templateTasks, TaskStatus taskStatus) in E:\Products\iAPISWeb\iapisprod14sep\head\iAPIS_9.0.1\src\ASL.iAPIS.Application\ApiaryProjectCustomApp\ApiaryActionsService.cs:line 473
at ASL.iAPIS.ApiaryProjectCustomApp.ApiaryActionsService.CreateTasksAsync(CreateTaskDto createTasks, Boolean updateCache) in E:\Products\iAPISWeb\iapisprod14sep\head\iAPIS_9.0.1\src\ASL.iAPIS.Application\ApiaryProjectCustomApp\ApiaryActionsService.cs:line 767
3 Answer(s)
-
0
Hi @Leonardo.Willrich
Is it possible to share related app service method code with us as well ?
-
0
Hi,
It is a huge code that calls several methods from different classes/services. It would be easier having a remote session and I can show where is the entry point and where is the line throwing the exception, if it is possible.
-
0
Hi,
Could you send it to (just the entry app service method will be enough I guess) [email protected] ? By the way, it is not a good practice to call one app service from another app service. Since there is interception when calling an app service, it might cause such problems.