I have issue with Background job tries. Job are created in AbpBackgroundJobs table and executed once. After job failed, job record in the table is not updated: NextTryTime is still equesl to CreationTime and TryCount is 0. Even 1 day after failed jobs are in db and not updated.
Log:
WARN 2020-04-20 16:45:17,272 [14 ] Abp.BackgroundJobs.BackgroundJobManager - 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.microso$
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 inform$
---> 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/?$
at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ThrowAggregateUpdateConcurrencyException(Int32 commandIndex, Int32 expectedRowsAffected, Int32 rowsAffected)
at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ConsumeResultSetWithoutPropagation(Int32 commandIndex, RelationalDataReader reader)
at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.Consume(RelationalDataReader reader)
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(DbContext _, ValueTuple`2 parameters)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable`1 commandBatches, IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList`1 entriesToSave)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Abp.EntityFrameworkCore.AbpDbContext.SaveChanges()
--- End of inner exception stack trace ---
at Abp.EntityFrameworkCore.AbpDbContext.SaveChanges()
at Abp.Zero.EntityFrameworkCore.AbpZeroCommonDbContext`3.SaveChanges()
at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.SaveChangesInDbContext(DbContext 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 Castle.DynamicProxy.AbstractInvocation.Proceed()
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Abp.BackgroundJobs.BackgroundJobManager.TryProcessJob(BackgroundJobInfo jobInfo)
DEBUG 2020-04-20 16:45:17,274 [14 ] HttpRequestEntityChangeSetReasonProvider - Unable to get URL from HttpRequest, fallback to null
WARN 2020-04-20 16:45:17,275 [14 ] Abp.BackgroundJobs.BackgroundJobManager - 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 e$
---> 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/?$
at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ThrowAggregateUpdateConcurrencyException(Int32 commandIndex, Int32 expectedRowsAffected, Int32 rowsAffected)
at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ConsumeResultSetWithoutPropagation(Int32 commandIndex, RelationalDataReader reader)
at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.Consume(RelationalDataReader reader)
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(DbContext _, ValueTuple`2 parameters)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable`1 commandBatches, IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList`1 entriesToSave)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Abp.EntityFrameworkCore.AbpDbContext.SaveChanges()
--- End of inner exception stack trace ---
at Abp.EntityFrameworkCore.AbpDbContext.SaveChanges()
at Abp.Zero.EntityFrameworkCore.AbpZeroCommonDbContext`3.SaveChanges()
at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.SaveChangesInDbContext(DbContext 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 Castle.Proxies.IRepository`2Proxy_1.Update(BackgroundJobInfo entity)
at Castle.Proxies.BackgroundJobStoreProxy.Update_callback(BackgroundJobInfo jobInfo)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Abp.BackgroundJobs.BackgroundJobManager.TryUpdate(BackgroundJobInfo jobInfo)
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 inform$
---> 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/?$
at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ThrowAggregateUpdateConcurrencyException(Int32 commandIndex, Int32 expectedRowsAffected, Int32 rowsAffected)
at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ConsumeResultSetWithoutPropagation(Int32 commandIndex, RelationalDataReader reader)
at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.Consume(RelationalDataReader reader)
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(DbContext _, ValueTuple`2 parameters)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable`1 commandBatches, IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList`1 entriesToSave)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Abp.EntityFrameworkCore.AbpDbContext.SaveChanges()
--- End of inner exception stack trace ---
at Abp.EntityFrameworkCore.AbpDbContext.SaveChanges()
at Abp.Zero.EntityFrameworkCore.AbpZeroCommonDbContext`3.SaveChanges()
at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.SaveChangesInDbContext(DbContext 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 Castle.Proxies.IRepository`2Proxy_1.Update(BackgroundJobInfo entity)
at Castle.Proxies.BackgroundJobStoreProxy.Update_callback(BackgroundJobInfo jobInfo)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Abp.BackgroundJobs.BackgroundJobManager.TryUpdate(BackgroundJobInfo jobInfo)
You can see 2 exceptions there. They are AbpDbConcurrencyException. First occured during job precessing. The second - TryUpdate background job.
Code of Execute method of Background Job
public override async void Execute(DefectPhotoUploaderBackgroundJobArgs args)
{
using (var unitOfWork = UnitOfWorkManager.Begin())
{
string photoUrl = await _cloudStorage.UploadFileAsync(args.Image, "image_123.jpg");
await _backgroundJobManager.EnqueueAsync<DefectPhotoUrlSaverBackgroundJob, DefectPhotoUrlSaverBackgroundJobArgs>( <<< I think first exception occured because of this operation. There is one more backgroud job created
new DefectPhotoUrlSaverBackgroundJobArgs()
{
InspectionGuid = args.InspectionGuid,
DefectId = args.ProductInstanceInspectionDefect.DefectId,
PhotoUrl = photoUrl
});
unitOfWork.Complete(); <<< SaveChanges called. it is failed with the exception
}
} <<< Job Manager tryes to update status of failed job and gets the exception.
it is important to mention that AbpBackgroudJobs table contains many of records (1000+).
Can you please to help with the issue?
Also can you please answer on questions about manager:
ANZ version: 8.0.0
Thanks
I need to modify current api/TokenAuth/Authenticate
method. This method uses userNameAndMail and password fields for authentification. I am looking for a way to add a couple of fields to the AbpUser and use them in certain way I need. Is that possible?
Thanks
I am using Azure DevOps CI. I have question about databe migrations run from pipline. My release pipline is executed on production server (self-hosted agent). Could you provide an example or way how to execute migration? I am asking becuase I am bit confused with way provided in ANZ doc https://docs.aspnetzero.com/en/aspnet-core-mvc/latest/Setting-Up-an-Azure-Pipeline-Mvc-Core. It offers simple way: generate sql script from migrations files and excute it. But at the same time in the Get Started section documentation says to use the migrator app that works a bit different. Could you advise about migrations with azure pipline on self-hosted agent?
Hi,
Are there any plans to upgrage ANZ with .net 3.0. I tryed to figured out that on forum but I am not able to pen links from https://support.aspnetzero.com/QA/Questions/7826: alway 404 error. My github account is invited to anz client team. So, any plans? Also is it safe to update ANZ 7 with .net 3.0?
Hi,
I need preporcess json payload on API call request, eg remove prefixes in name properties on json objects:
{ foo.bar.item: "value" }
to
{ item: "value" }
I need do this because not all API users can send data in required format. Can that be done within ANZ or that shold be done with ASP.NET Core only? I guess that can be done with middleware, I will very appreciate if you will show example
Thanks
Hi,
I use modular system of abp. Each module has own localization source (xml file). As I found Angular app uses one localization source with name predefined in const variable AppConsts.localization.defaultLocalizationSourceName. Is it possible to specify different localization source name for different modules on angular app?
Hi,
I am using dynamic API. I would like to know if it is possible to return always 200 http status code and use error code files on API response. Currently I am getting API error via http response status and error code field is always 0.
Thanks